Skip to Content
0
Dec 22, 2015 at 07:33 AM

ABAP OLE - How to copy format from one line to given range.

1026 Views

HI ,

I am doing project, which involve populating data in Excel file.

For the same, I am using SAP OLE .

Now, I struck when I am trying to copy format of a row to the given range.

Details of problem is as follows :-

  1. I have a row no. say 15, which contains the required format I am looking in other lines. So I copy the line.
  2. I have selected range as rows 13 and 14 , where I need to paste format. I use "paste special " feature to paste the format in row 13 and 14.

In macro , the VBScript for the above operation is :-

Rows("15:15").Select

Selection.Copy

Rows("13:14").Select

Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _

SkipBlanks:=False, Transpose:=False

So I tried to translate the same in ABAP as below :-

*Rows("15:15").Select

CALL METHOD OF

g_active_sheet

'ROWS' = v_source_obj

EXPORTING

#1 = p_source

#2 = p_source.

CALL METHOD OF

v_source_obj

'SELECT'.

* selection.copy

CALL METHOD OF

g_excel_application

'SELECTION' = v_selection_obj.

CALL METHOD OF

v_selection_obj

'COPY'.

* rows("13:14").Select

CALL METHOD OF

g_active_sheet

'ROWS' = v_range_obj

EXPORTING

#1 = p_from

#2 = p_to.

CALL METHOD OF

v_range_obj

'SELECT'.

CALL METHOD OF

v_selection_obj

'PASTESPECIAL'

EXPORTING

#1 = 'paste:=xlpasteformats'

#2 = -4142

#3 = 0

#4 = 0.


Please suggest what wrong I am doing here.

Regards,

Ekam