我正在尝试从 Excel 调用 SAP 事务,我使用了许多来自 Internet 的代码,但仍然失败。不管我使用什么代码,我总是收到相同的错误消息
脚本正在打开与系统 SYSTEM 的连接
比错误说:
运行时错误 1000 错误描述不可用”
比调试后它在下面以黄色突出显示
Set Connection = SapGuiApp.OpenConnection("SYSTEM", True)
它一直在用我试图拉出的所有代码来做这件事。
代码
Dim sap As Object
Dim conn As Object
Sub T_login()
Set sap = CreateObject("SAP.Functions")
Set conn = sap.Connection
conn.System = "SYSTEM"
conn.client = "603"
conn.user = "LANAX001"
conn.Password = "alamzeb4"
conn.Language = "EN"
If conn.logon(0, False) Then
MsgBox "Logon to the SAP system is not possible", vbOKOnly, "Comment"
Else
End If
If Not IsObject(SapGuiApp) Then
Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
If Not IsObject(Connection) Then
Set Connection = SapGuiApp.OpenConnection("SYSTEM", True)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
'launch a transaction
session.findById("wnd[0]").Maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "FS10N"
session.findById("wnd[0]").sendVKey 0
End Sub