我花了几个小时发现问题。 我想用ini文件启动SAP Logonpad,可以正常工作。 然后绑定到脚本对象后,我想打开连接到具有connection = SapGui.OpenConnection(“SID”,True) 的特定系统,但始终会使运行时错误70访问被拒绝。VBA Excel SSO到SAP /运行时错误70“访问被拒绝”
我跟着别人似乎做的与vbs,某些resons我不能用vbs做它,必须与vba,所以也许可能有一些差异,使它失败?
任何意见将不胜感激。
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
服务器上的脚本处于活动状态。我只是取消了SAP Gui的设置来警告脚本是否连接。奇怪的是,它只打开了一次SAP系统登录屏幕。现在我得到运行时错误438对象不支持这个属性或方法。 – JonSnow