【发布时间】:2017-08-02 19:35:07
【问题描述】:
我想为我的作品自动化一些操作,所以我在 SAP GUI(SAP LOGON PAD 720)上录制了一个脚本,然后用它来创建一个 excel 宏,它在我的计算机上完美运行,但是当我尝试运行它时在其他计算机中,它根本不起作用,当我在其他 PC 中记录相同的过程时,脚本的代码与我的 PC 中出现的代码不同。我想知道这怎么可能,我怎样才能在我的电脑上更改“代码形式”或“代码语言”,以便在我录制脚本时可以在每台计算机上使用它。
这是我电脑上的脚本
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 = "vl03n"
session.findById("wnd[0]").sendVKey 0
'This is the script I recorded from my computer,in other pc this "LIKP-VBELN" doesnt appear
session.findById("wnd[0]/usr/ctxtLIKP-VBELN").text = "8105148724"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[7]").press
如果我从其他电脑上记录相同的过程
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 = "vl03n"
session.findById("wnd[0]").sendVKey 0
'here is when the error begin "LIKP-VBELN" doesnt appear anymore so that is why the macro doesnt work
session.findById("wnd[0]/usr/ctxt").text = "8105148724"
session.findById("wnd[0]/usr/ctxt").caretPosition = 10
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[7]").press
【问题讨论】: