Skip to Content
0

Proper Method for Exporting SAP to Excel via VBA

Feb 13, 2017 at 04:43 AM

78

avatar image

I utilize EXCEL VBA scripting to :

Open SAPGUI

Logon SAP 740

Assure that I am on SAP EASY ACCESS

Start Transaction IW49N

Populate the fields (Plant, Planning Group, Start Dates/EndDates, Layout etc)

Initate the query.

Once the data is retrieved, it asks that the Results to be exported to EXCEL as a Table, and SAP responds by opening a Excel File (“Worksheet in Basis (1)”) in a SEPARATE INSTANCE of Excel (ie differ than the instance I am utilizing).

Originally, even though it was a separate instance – I could still “sense” the file via the Excel VBA Project List. Hence I could change to the SAP Generated file, Select All cells, copy it over to MY Excel Workbook, then return to SAP (scripting) to close out the SAP generated Instance (“Worksheet in Basis (1)”)

That worked for a few months…. Then suddenlyI was no longer to see the SAP generated file (“Worksheet in Basis (1)”) in the Excel my Excel VBA Project List… So I started using Window API Codes, to find the File and the window Handle.This allowed me to use Window API codes to Activate the window as Excel and hence, Copy the content of the spreadsheet….

Now that stopped working…

So … What is the Proper way of Extracting the contents off the SAP Generated Worksheet?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers