Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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"

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

   

   

    WScript.Sleep 10000

    Set Wshell = CreateObject("Wscript.Shell")

    Do

    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

Former Member
Not what you were looking for? View more on this topic or Ask a question