1 year ago

#378971

test-img

joshn1117

Why am I getting an invalid procedure or call error in my VBA code to link to SAP

I'm trying to link my SAP to excel so that I can automate some report creating, but I seem to be unable.

I copied this code exactly

Sub SapExport()
If Not IsObject(SAPapplication) Then
Set SapGuiAuto = GetObject(“SAPGUI”)
Set SAPapplication = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(SAPconnection) Then
Set SAPconnection = SAPapplication.Children(0)
End If
If Not IsObject(SAPsession) Then
Set SAPsession = SAPconnection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject SAPsession, “on”
WScript.ConnectObject Application, “on”
End If

from this article into the code for my workbook and received an "invalid procedure or call" error when I tried to run. I did add an End Sub at the end because it refused to run without that. Any help is appreciated thanks. Once I get the connection functioning I figure it should be fairly straightforward as I'm decently familiar with writing simple scripts in VBA.

ETA the error is occurring inside the first if statement

excel

vba

sap-gui

0 Answers

Your Answer

Accepted video resources