Skip to Content
Former Member
Aug 14, 2015 at 12:43 PM

VBA Code to export data from SAP and save to Desktop


Hi Script Gurus,

Good day.

I just wanna ask for your help in figuring out what is the solution to my problem.

I want to export a report in SAP and save it as PDF. When i click the "Ok" button to save the report, a new dialog box with name "Pdf995 Save As" appear after 3 seconds. Im trying to control the dialog box using SendKeys but it is not working. Below is the code:

Please help.

session.findById("wnd[1]/usr/cmbPRIPAR_EXT-OSPRINTER").Key = "PDF995"


WScript.Sleep 10000

Set Wshell = CreateObject("Wscript.Shell")


bWindowFound = Wshell.AppActivate("Pdf995 Save As")

WScript.Sleep 1000

Loop Until bWindowFound

WScript.Sleep 5000

bWindowFound = Wshell.AppActivate("Pdf995 Save As")

If (bWindowFound) Then

WScript.Sleep 5000

Wshell.AppActivate "Pdf995 Save As"

WScript.Sleep 100

Wshell.SendKeys ("Parked and Blocked Report" & " " & Format(Date, "mmddyyyy") & ".pdf")

WScript.Sleep 100

Wshell.SendKeys ("{ENTER}")

WScript.Sleep 100

End If