Thanks Stefan. I tried but im not getting any luck. ![]()
i pasted below my whole code. can you check if i missed any declaration or variant etc?
Im feeling hopeless now. ![]()
Thanks
Sub Sap_DownPDF()
Dim application
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
'Start the transaction to view a table
session.findById("wnd[0]/tbar[0]/okcd").Text = "/N/DS1/MM_C_BLK_PARK23"
session.findById("wnd[0]").sendVKey 0
'Update the Company Code
session.findById("wnd[0]/usr/ctxtS_BUKRS-LOW").Text = Sheets("Home").Range("K4").Value
session.findById("wnd[0]/usr/txtS_GJAHR-LOW").Text = Sheets("Home").Range("K5").Value
session.findById("wnd[0]/usr/txtS_GJAHR-HIGH").Text = Sheets("Home").Range("M5").Value
session.findById("wnd[0]/usr/ctxtS_BLART-LOW").SetFocus
session.findById("wnd[0]/usr/ctxtS_BLART-LOW").caretPosition = 0
session.findById("wnd[0]/usr/btn%_S_BLART_%_APP_%-VALU_PUSH").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/tbar[0]/btn[8]").press
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/tbar[0]/btn[86]").press
session.findById("wnd[1]/usr/ctxtPRI_PARAMS-PDEST").Text = "LOCL"
session.findById("wnd[1]/tbar[0]/btn[6]").press
session.findById("wnd[2]/tbar[0]/btn[0]").press
session.findById("wnd[2]/tbar[0]/btn[13]").press
session.findById("wnd[1]/usr/cmbPRIPAR_EXT-OSPRINTER").Key = "PDF995"
Set Wshell = CreateObject("WScript.Shell")
session.findById("wnd[1]/tbar[0]/btn[13]").press
WScript.Sleep 10000
Set Wshell = CreateObject("Wscript.Shell")
Do
WScript.Sleep 100
bWindowFound = Wshell.AppActivate("Pdf995 Save As")
Loop Until bWindowFound
Wshell.SendKeys ("Parked and Blocked Report" & " " & Format(Date, "mmddyyyy") & ".pdf")
WScript.Sleep 100
Wshell.SendKeys ("{ENTER}")
WScript.Sleep 100
End Sub