Reputation: 23
I have the code below that I was using to export PDF from SAP. It was working on previous SAP version, but now it gets "runtime error 438, object doesn't support this property or method" on Browserhandle.locationURL.
Could you please give me a hint what should I change?
Call SAPopen(SystemName, SystemID, TransID)
session.findById("wnd[0]").maximize
For i = 6 To lastInv
invRef = Cells(i, 2)
invName = Cells(i, 3)
fileName = fPath & invName & ".pdf"
If FileExists(fileName) = True Then fileName = fPath & invName & "i" & ".pdf"
session.findById("wnd[0]/usr/ctxtVBRK-VBELN").Text = invRef
session.findById("wnd[0]/mbar/menu[0]/menu[11]").Select
If session.ActiveWindow.Name = "wnd[0]" Then
Message = "No output exists"
GoTo WriteMsg
End If
session.findById("wnd[1]/usr/tblSAPLVMSGTABCONTROL").getAbsoluteRow(0).Selected = True
session.findById("wnd[1]/tbar[0]/btn[37]").press
If session.ActiveWindow.Name = "wnd[1]" Then
Message = "No output could be opened"
GoTo WriteMsg
End If
session.findById("wnd[0]/tbar[0]/okcd").Text = "pdf!"
session.findById("wnd[0]").sendVKey 0
pdfLocL = session.findById("wnd[1]/usr/cntlHTML/shellcont/shell").Browserhandle.locationURL
pdfLocStart = InStr(pdfLocL, "C:")
pdfLocS = Mid(pdfLocL, pdfLocStart, 9999)
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.copyfile pdfLocS, fileName
If FileExists(fileName) = True Then Message = "Invoice saved" Else Message = "Invoice not saved"
session.findById("wnd[1]").Close
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[1]").Close
Set FSO = Nothing
Upvotes: 0
Views: 281