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

Excel Range.End property

Former Member
0 Likes
487

Hi all -

I'm trying to find the end of my spreadsheet without looping through every row. I can do this in VBA as follows:


Selection.End(xlDown)

I tried to implement in ABAP like this. I have omitted the code where I set the selection, that is working & verified by setting my Excel application Visible.


CONSTANTS: c_xldown VALUE -4121.
DATA: w_xlrng TYPE ole2_object, w_xlendrng TYPE ole2_object.
GET PROPERTY OF w_xlrng 'End' = w_xlendrng
  EXPORTING
  #1 = c_xldown.

The above code sets SY-SUBRC to 4.

Does anyone know how to implment this capability?

Many thanks,

Tim

2 REPLIES 2
Read only

Former Member
0 Likes
416

Can we know the reason for this.

May based on your requirement some other opition we can given.

Read only

0 Likes
416

Solved my own problem, which was caused by incorrect constant definition.

This works:


CONSTANTS: c_xldown    TYPE i VALUE -4121.

    " (code omitted) ... open file, position selection at row & column where data starts
    GET PROPERTY OF w_xlrng 'End' = w_xlendrng
      exporting
      #1 = c_xldown.

The problem was, without TYPE i, the default data type was c, which resulted in incorrect information being sent to Excel.

My overall goal is to read a very large Excel spreadsheet into a table without running out of memory - I was getting short dumps when the system was unable to extend internal table space. The End(xlDown) property wasn't absolutely required, but I wanted to provide the user some feedback as to how we're progressing by counting rows before actually processing them.

Thanks,

Tim