Skip to Content
0
Jun 13, 2020 at 10:51 AM

SAP spreadsheet export with non-scriptable window

885 Views Last edit Jun 15, 2020 at 04:04 AM 2 rev

Hi,

I have a code on exporting spreadsheet from a query with non-scriptable "Save As" window. Concept of the code was provided by answers.sap.com User. I have 2 issues with the code. Could you please advise?

This is the part of the code for the export:

'Export to spreadsheet - first 2 lines are recorded when I do the export with recording, and when running it works well, opens the non-scriptable "Save As" window

session.FindById("wnd[0]/usr/cntlCONTAINER/shellcont/shell").pressToolbarContextButton "&MB_EXPORT" session.FindById("wnd[0]/usr/cntlCONTAINER/shellcont/shell").SelectContextMenuItem "&XXL"

'Start asynchronous process

Set WshShell = CreateObject("WScript.Shell") WshShell.Run "C:\Users\AAA.LOGON\Documents\AAA\ScriptCA.vbs"

'-Begin-----------------------------------------------------------------

Set wshShell = CreateObject("WScript.Shell")

Do

WScript.Sleep 500

Loop Until wshShell.AppActivate("Save As") = True

wshShell.Sendkeys "%nNA_SQ00FBL5N_CA10.XML"

'wshShell.Sendkeys "%nNA_SQ00FBL5N_CA10.XML%f"

'-End-------------------------------------------------------------------

Issue 1 is that I do not know how to get "Save" button pressed by the macro, your suggestion did not work for me.

Issue 2 is that I run 3 queries within the same macro and I would like to export all 3 files in XML format with different names and I have 3 scripts referenced. When running the macro file names are filled randomly, not according to the scripts. It seems to me that the first file name is filled twice and then the second comes instead of the third and then would the third come if I had a fourth query.