Reputation: 9
I want to start the SAP LogonPad with the .ini
file, that works fine.
Then after binding to the scripting object I want to open the connection to a specific System with connection = SapGui.OpenConnection("SID", True)
but I always get this error:
runtime error 70 access denied.
I followed what others seem to do with VBS, for certain reasons I can't do it with VBS and have to go with VBA, so maybe there might be some difference that makes it fail?
Any advice would be highly appreciated.
Private Sub CommandButton1_Click()
Dim SapGui As Object
Dim saplogon As Object
Dim connection 'As Object
Set SapGui = GetObject("SAPGUI")
Dim Wshshell As Object
Set Wshshell = CreateObject("Wscript.Shell")
Wshshell.Run Chr(34) & ("C:\Program Files\SAPPC\FrontEnd\SAPgui
\saplogon.exe") & Chr(34) & " " & "/INI_FILE" & "=" & Chr(34) &
"\\longpathtoini\appl\Sap\saplogon\int\saplogon.ini" & Chr(34)
Do Until Wshshell.AppActivate("SAP Logon")
Application.Wait Now + TimeValue("0:00:01")
Loop
Set Wshell = Nothing
Set saplogon = SapGui.GetScriptingEngine
connection = SapGui.OpenConnection("SID", True)
Set SapGui = Nothing
Set saplogon = Nothing
Set connection = Nothing
End Sub
Upvotes: 0
Views: 2993
Reputation: 9
Thanks to vwegert.
I surely knew about scripting needs to be enabled on the servers. Which is, but at the moment I read his answer I remembered that in my SAP GUI settings the checkbox for "Warn if a script tries to connect" was enabled.
Disabeling that options did lead to success.
The above code works perfectly.
Upvotes: 0
Reputation: 18493
Check whether user scripting is allowed for the particular system (transaction RZ11
, parameter sapgui/user_scripting
). Also be aware that for some versions, you'll apparently need to specify the SAP Logon entry text instead of the SID.
Upvotes: 1