在较小的修改下,封闭的脚本已预先记录在ECC 6.0(SAP的较新版本)中。该脚本运行良好,但是,将其复制到excel VBA中后,该宏不会调用ECC 6.0窗口。任何人都可以帮助缺少的东西吗?
Sub Test()
If Not IsObject(SAPGuiApp) Then
Set SAPGuiAuto = GetObject("SAPGUI")
Set SAPGuiApp = SAPGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = SAPGuiApp.Children(0)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject SAPGuiApp, "on"
End If
session.findById("wnd[0]").resizeWorkingPane 134, 23, False
session.findById("wnd[0]/tbar[0]/okcd").Text = "/n/sapapo/mdo4"
session.findById("wnd[0]").sendVKey 0
End Sub