VBA连接到SAP GUI,但不连接到SAP NW Business Client 5

时间:2019-04-11 09:02:23

标签: excel vba sap

我使用以下代码行将VBA连接到SAP GUI会话,并且效果很好:

Sub Change_date()

Dim SapGuiAuto
Dim SetApp
Dim Connection
Dim Session

Set SapGuiAuto = GetObject("SAPGUI")
Set SetApp = SapGuiAuto.GetScriptingEngine
Set Connection = SetApp.Children(0)
Set Session = Connection.Children(0)
'And so on.

但是,这在SAP NetWeaver Business Client 5的SAP GUI中不起作用。

SAP GUI: SAP GUI

SAP NW Business Client 5中的SAP GUI: SAP GUI inside SAP NW Business Client 5

如何更改代码使其适用于SAP GUI和SAP NW Business Client?

1 个答案:

答案 0 :(得分:1)

代替    Set SapGuiAuto = GetObject("SAPGUI")
我用了     Set SapGuiAuto = GetObject("SAPGUISERVER") 这使我的代码在Neveawer上工作。