提问人:syed jee 提问时间:11/1/2023 最后编辑:JohnMsyed jee 更新时间:11/5/2023 访问量:49
用于从 SAP IE03 中的设备下载附件的脚本
Script to download attachment from Equipment in SAP IE03
问:
我有一个脚本可以通过“IE03”从设备下载附件。当我运行该命令时,它运行良好,直到有一个没有附件的设备,所以我想跳过它并在循环中移动到下一行。
问题出在这条线上:
session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_VIEW_ATTA" )
以下是程序
Private Sub CommandButton1_Click()
' Define all variables
Dim SapGuiAuto, Application, Connection, session As Object
Set SapGuiAuto = GetObject("SAPGUI")
Set Application = SapGuiAuto.GetScriptingEngine
Set Connection = Application.Children(0)
Set session = Connection.Children(0)
Dim i, start_line, finish_line As Integer
start_line = 64
finish_line = 364
' Start processing
For i = start_line To finish_line ' start of loop
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/NIE03"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtRM63E-EQUNR").Text = Cells(i, 1).Value
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"
session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_VIEW_ATTA"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectedRows = "0"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").pressToolbarButton "%ATTA_EXPORT"
session.findById("wnd[1]/usr/ctxtDY_PATH").Text = "C:\Users\GGC8045\OneDrive - MDLZ\desktop\Chicago 8364\DOCUMENTS"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").Text = Cells(i, 1).Value
session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 8
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/tbar[0]/btn[12]").press
session.findById("wnd[0]").sendVKey 12
session.findById("wnd[0]").sendVKey 12
Cells(i, 5).Value = "Done at " & Now()
Next i ' end of loop
End Sub
答: 暂无答案
评论