SAP GUI不运行VBScript脚本

SAP GUI不运行VBScript脚本

问题描述:

也许有SAP GUI和VBScripts经验的人可以帮助我。SAP GUI不运行VBScript脚本

我试图在SAP GUI

If Not IsObject(application) Then 
    Set SapGuiAuto = GetObject("SAPGUI") 
    Set application = SapGuiAuto.GetScriptingEngine 
End If 
If Not IsObject(connection) Then 
    Set connection= application.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 application, "on" 
End If 
session.findById("wnd[0]").maximize 
session.findById("wnd[0]/tbar[0]/okcd").text="cv04n" 
session.findById("wnd[0]").sendVkey 0 

我不断收到 错误运行下面的VBScript:服务器引发异常。 代码:80010105

此错误是在这一行:session.findById( “WND [0]”)最大化

服务器可以阻止我的脚本?

在SAP GUI配置中启用了SAPGUI脚本,但是当我尝试记录一个时,它不记录并且窗口中的符号始终表示该脚本正在运行但没有任何反应,并且不记录任何内容.vbs文件。 当我尝试在GUI中运行我的脚本时,会发生同样的情况,它将保持运行状态,但没有任何反应。

非常感谢。

+0

的可能的复制[HRESULT:0x80010105(RPC \ _E \ _SERVERFAULT)问题](http://*.com/questions/973206/hresult-0x80010105-rpc-e-serverfault - 问题) – Lankymart

+0

我怎么知道是什么导致这个错误? – user3452550

+0

也许这将有助于 - [错误0x80010105(RPC_E_SERVERFAULT)使用SAP Scripting API](https://archive.sap.com/discussions/thread/3824444) – Lankymart

此:

Set application = SapGuiAuto.GetScriptingEngine 

正因为如此,你将永远无法获得SAP的脚本引擎,“应用”属于Excel中,你不能将其设置为外部应用程序。

将其更改为:

Set sapapplication = SapGuiAuto.GetScriptingEngine 

让我给你完整的代码示例:

Set sapguiauto = GetObject("SAPGUI") 
    Set sapapplication = sapguiauto.GetScriptingEngine 
    Set connection = sapapplication.Children(0) 
    Set session = connection.Children(0) 

现在你有SAP会话。用它做任何事情。

喜欢:

session.findById("wnd[0]/sbar").Text 
session.findById("wnd[0]").maximize 
session.findById("wnd[0]/tbar[0]/okcd").text="cv04n" 
session.findById("wnd[0]").sendVkey 0