2012 May 23 9:46 AM
Hi Experts,
Can someone help me in converting the Excel Macro code to ABAP?
I tried this way, but it is not working.
For X-Axis Title:
Here's the VBScript:
With ActiveChart
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Date"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "MB"
End With
ActiveChart.ChartType = xlLineMarkers
End Sub
And my ABAP Code which is not working:
GET PROPERTY OF h_chart3 'AxisTitle' = h_xaxis.
GET PROPERTY OF h_xaxis 'Characters' = h_xaxis.
SET PROPERTY OF h_xaxis 'text' = l_xaxis.
*
* GET PROPERTY OF h_chart3 'AxisTitle' = h_yaxis.
* GET PROPERTY OF h_yaxis 'Characters' = h_yaxis.
* SET PROPERTY OF h_yaxis 'text' = l_yaxis.
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlBottom
Const xlBottom = -4107 (&HFFFFEFF5)
* Making the Legend to display at the Bottom of the Chart
SET PROPERTY OF h_chart3 'HasLegend' = 1.
GET PROPERTY OF h_chart3 'Legend' = h_legend.
* GET PROPERTY OF h_legend 'Select' = h_legend.
CALL METHOD OF
h_legend
'Select'.
SET PROPERTY OF h_legend 'Position' = '-4107'. " '&HFFFFEFF5'. " '-4107'.
ActiveChart.SeriesCollection(2).Select
With Selection.Border
.ColorIndex = 3
.Weight = xlThin
.LineStyle = xlDot
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
Please do help. Thanks!!
Rgards,
Sowmya
2012 May 25 10:07 AM
At last, I got the answer for this.
Kartik helped me. Thanks to Kartik
Karthik, Thanks for your try too
Here's the code:
VBA:
With ActiveChart
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "MB"
End With
ActiveChart.ChartType = xlLineMarkers
End Sub
ABAP:
CALL METHOD OF h_chart3 'Axes' = h_yaxis
EXPORTING
#2 = 2. " xlPrimary
SET PROPERTY OF h_yaxis 'HasTitle' = 1.
GET PROPERTY OF h_yaxis 'AxisTitle' = h_yaxistitle.
GET PROPERTY OF h_yaxistitle 'Characters' = h_yaxistitle.
SET PROPERTY OF h_yaxistitle 'Text' = 'MB'.
We should get the reference of "Axes" first and then we have to GET / SET PROPERTY.
Regards,
Sowmya.
2012 May 23 10:00 AM
2012 May 23 10:06 AM
Thanks for the above link Karthik.
But I didn't find the scenario that I have. I had actually searched initially and when I couldn't solve it, hence posted in SCN.
Please do help in checking my code or please do correct it if it is wrong.
My code is not working. (Legend and X-Axis)
-Sowmya
2012 May 23 10:21 AM
2012 May 23 11:23 AM
I did check the above document. It is useful. Perhaps, my Requirement is not there
2012 May 24 6:30 AM
2012 May 24 6:34 AM
Thanks Karthik.
I'm searching too. I'll definitely post once I get the Solution.
I also wanted the Excel doc to be opened in 2007 version instead of 2003.
2012 May 24 5:11 AM
Hey Experts,
Can someone please help me on this? I'm still trying to find out the correct code.
I also wanted to know if the code differs from Excel 2003 to Excel 2007 ?
Thanks & Regards,
Sowmya
2012 May 24 8:27 AM
Please refer to the following link
An Easy Reference for OLE Automation
2012 May 24 9:00 AM
2012 May 25 10:07 AM
At last, I got the answer for this.
Kartik helped me. Thanks to Kartik
Karthik, Thanks for your try too
Here's the code:
VBA:
With ActiveChart
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "MB"
End With
ActiveChart.ChartType = xlLineMarkers
End Sub
ABAP:
CALL METHOD OF h_chart3 'Axes' = h_yaxis
EXPORTING
#2 = 2. " xlPrimary
SET PROPERTY OF h_yaxis 'HasTitle' = 1.
GET PROPERTY OF h_yaxis 'AxisTitle' = h_yaxistitle.
GET PROPERTY OF h_yaxistitle 'Characters' = h_yaxistitle.
SET PROPERTY OF h_yaxistitle 'Text' = 'MB'.
We should get the reference of "Axes" first and then we have to GET / SET PROPERTY.
Regards,
Sowmya.