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
REM ADDED BY EXCEL *************************************
Dim objExcel
Dim objSheet, intRow, i
Set objExcel = GetObject(,"Excel.Application")
Set objSheet = objExcel.ActiveWorkbook.ActiveSheet
For i = 2 to objSheet.UsedRange.Rows.Count
COL1 = Trim(CStr(objSheet.Cells(i, 1).Value)) 'Column1 Agreement/Contract number
COL2 = Trim(CStr(objSheet.Cells(i, 2).Value)) 'Column2 New Valid to date
if isEmpty(objSheet.cells(i,3)) then
session.findById("wnd[0]/tbar[0]/okcd").text = "/nme32k"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtRM06E-EVRTN").text = COL1
session.findById("wnd[0]/usr/ctxtRM06E-EVRTN").caretPosition = 10
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[6]").press
session.findById("wnd[0]/usr/ctxtEKKO-KDATE").text = COL2
session.findById("wnd[0]/usr/ctxtEKKO-KDATE").setFocus
session.findById("wnd[0]/usr/ctxtEKKO-KDATE").caretPosition = 10
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[1]/usr/btnSPOP-OPTION1").press
objSheet.Cells(i, 3) = "Updated"
REM FINALIZATION CONTROL CHECK ************************
aux=col1 & " " & COL2
CreateObject("WScript.Shell").run("cmd /c @echo %date% %time% " & aux & " >> C:\SCRIPT\PlOrCreationLog.txt")
End if
next
msgbox "Process Completed"
REM FINALIZATION CONTROL CHECK ************************ ```
SAP GUI 脚本如何测试消息的存在
下载声明:
本站所有软件和资料均为软件作者提供或网友推荐发布而来,仅供学习和研究使用,不得用于任何商业用途。如本站不慎侵犯你的版权请联系我,我将及时处理,并撤下相关内容!
session.findById("wnd[0]/tbar[0]/btn[11]").press
If session.ActiveWindow.Name = "wnd[1]" then
session.findById("wnd[1]/usr/btnSPOP-OPTION1").press
objSheet.Cells(i, 3) = "Updated"
else
objSheet.Cells(i, 3).Value = session.findById("wnd[0]/sbar").Text
End if