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

Selecting multiple Ranges in Excel using OLE

Former Member
0 Likes
2,154

Hi Experts,

Is there any method by which we can select multiple ranges in excel using OLE. For single range selection i am using the below code. As we select multiple ranges in the Excel sheet manually using CTRL button, likewise i want to know whether there is any method in OLE to select multiple ranges at a time.

CALL METHOD OF gv_application 'RANGE' = gv_range

EXPORTING #1 = lv_low

#2 = lv_high.

CALL METHOD OF gv_range 'SELECT'.

Thanks,

Shiva.

4 REPLIES 4
Read only

Former Member
0 Likes
1,183

Hi SIva ,

To the extend i remember we provide the first and last cell as input to the range , now since you want to select multiple ranges , i would suggest you to use the code provide by you

CALL METHOD OF gv_application 'RANGE' = gv_range

EXPORTING #1 = lv_low

#2 = lv_high.

CALL METHOD OF gv_range 'SELECT'.

multiple times with different values of lv_low and lv_high.

You can see how the system behaves by setting the visibility parameter of the application as 1 .

Do reply in case you have any further concerns .

Regards,

Arun

Read only

0 Likes
1,183

Hi Arun,

I have already tried that. When it executes code for second RANGE, First range is getting refreshed and selecting the second range. But it should select First and Second, should not refresh any range.

Thanks,

Shiva.

Read only

Former Member
0 Likes
1,183

/people/alvaro.tejadagalindo/blog/2009/02/05/excel-ole-and-abap--create-fancy-reports

Read only

Former Member
0 Likes
1,183

Shiva,

Did you ever get an answer to this question? I"m having the same issue and would appreciate any help you could provide.

When I perform a macro recording in excel, I can see the range being done two differnt ways...

Option 1: Range selecting from/to

Range("B12:F12").Select

Optioin 2: Range selecting a set of cells (not continuous) <-----this is what I'm trying to do via ABAP OLE Automation

Range("B5,E5,G5").Select

Range("G5").Activate

Here is the code I"m using...

call method of sheet 'Cells' = l_cell1 "select cell B13

EXPORTING #1 = 13

#2 = 2.

call method of sheet 'Cells' = l_cell2 "select cell M13

EXPORTING #1 = 13

#2 = 13.

call method of sheet 'Range' = l_range "setup range, not this actual does option 1 which is not what i want

EXPORTING #1 = l_cell1

#2 = l_cell2.

CALL METHOD OF l_range 'Select'.

....(between here there is some code setting up the chart)

CALL METHOD OF pie_chart 'SetSourceData' EXPORTING #1 = l_range

#2 = 1. "1 = plot as row, 2 = plot as column

Result: Chart is created with all cells between column 2 to 13. But I just want a chart of coumn 2 and 13.