我想为我的作品自动执行某些操作,因此我在SAP GUI上记录脚本(SAP LOGON PAD 720),然后使用它创建一个excel宏,它在我的计算机上运行完美,但是当我尝试运行它时在其他计算机中,它根本不起作用,当我在其他PC中记录相同的进程时,脚本的代码与我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
如果我从其他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
'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
答案 0 :(得分:0)
检查客户端的LAN连接并确保其设置为“高速”。
此致 ScriptMan