cancel
Showing results for 
Search instead for 
Did you mean: 

VB Code to continue with SAVE AS dialog window

Former Member
0 Kudos

Hello,

I've followed a couple of order posts here nearly asking the same question, but no definitive answers have been posted so I'm trying my luck to see if anyone has came up with a solution.

First I'm running SAP Version 730;

I have the following VBS Script that works great, basically it pulls a report and then once completed gives me the option to Save As an Excel file.  At this point I need more help with VBS (I'm not expert by far) to populate the Save As window information (i.e. file name and file location) and then click save (and if I'm hoping for everything, also if there's an existing file to say "yes" to overwrite it, has anyone done this or is this possible? (see Image Below)

Option Explicit

Dim WSHShell, application, connection, session, SapGuiAuto

Set WSHShell = WScript.CreateObject("WScript.Shell")

If Not IsObject(application) Then

   Set SapGuiAuto  = GetObject("SAPGUI")

   Set application = SapGuiAuto.GetScriptingEngine

End If

If Not IsObject(connection) Then

   Set connection = application.Children(0)

End If

If Not IsObject(session) Then

   Set session    = connection.Children(0)

End If

If IsObject(WScript) Then

   WScript.ConnectObject session,     "on"

   WScript.ConnectObject application, "on"

End If

session.findById("wnd[0]").maximize

session.findById("wnd[0]/tbar[0]/okcd").text = "ReportNameHere"

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/ctxtS_VKORG-LOW").text = "LocationHere"

session.findById("wnd[0]/usr/ctxtS_VKORG-LOW").caretPosition = 4

session.findById("wnd[0]/usr/btn%_S_AREA_%_APP_%-VALU_PUSH").press

session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/txtRSCSEL_255-SLOW_I[1,0]").text = "Criteria1"

session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/txtRSCSEL_255-SLOW_I[1,0]").text = "Criteria2"

session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/txtRSCSEL_255-SLOW_I[1,1]").text = "Criteria3"

session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/txtRSCSEL_255-SLOW_I[1,2]").setFocus

session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/txtRSCSEL_255-SLOW_I[1,2]").caretPosition = 4

session.findById("wnd[1]/tbar[0]/btn[0]").press

session.findById("wnd[1]/tbar[0]/btn[8]").press

session.findById("wnd[0]/tbar[0]/btn[0]").press

session.findById("wnd[0]/tbar[1]/btn[8]").press

session.findById("wnd[0]").sendVKey 43

session.findById("wnd[1]/tbar[0]/btn[0]").press

'session.findById("wnd[1]/tbar[0]/btn[0]").press

My Screenshot:

Accepted Solutions (0)

Answers (1)

Answers (1)

holger_khn
Contributor
0 Kudos

Hello. There arme many definitive answers for MS SaveAs Dialogue handling in SAP.

oone Option is seperate vbs Script with sendkeys. The other one an second Excel instance where SaveAs can be handled via User32 API.

you definitely  find some helpful threads for both of them in SCN Forum.

br, Holger