Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Conversion from Excel Macros to ABAP code

Former Member
0 Likes
1,624

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,448

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.

10 REPLIES 10
Read only

Former Member
0 Likes
1,448
Read only

0 Likes
1,448

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

Read only

0 Likes
1,448

I did check the above document. It is useful. Perhaps, my Requirement is not there

Read only

0 Likes
1,448

I am searching on it.If u find it please post

Read only

0 Likes
1,448

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.

Read only

Former Member
0 Likes
1,448

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

Read only

Former Member
0 Likes
1,448

Please refer to the following link

An Easy Reference for OLE Automation

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/204d1bb8-489d-2910-d0b5-cdddb3227...

Read only

0 Likes
1,448

Hi Jack,

I've already referred this document.

-Sowmya

Read only

Former Member
0 Likes
1,449

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.