怎样让脚本自动停止运行?
我做了个vbs的脚本打印SAP凭证,按照参照号来。请问该怎么设置可以让脚本自动运行直到最后一张凭证?总不能1,2,3,4,5,6这样一段段写下去吧代码如下
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]").resizeWorkingPane 165,29,false
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").setCurrentCell -1,"XBLNR"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "XBLNR"
session.findById("wnd[0]/tbar[1]/btn[28]").press
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").currentCellColumn = "XBLNR"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/tbar[0]/btn[86]").press
session.findById("wnd[1]/tbar[0]/btn[13]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").currentCellRow = 1
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/tbar[0]/btn[86]").press
session.findById("wnd[1]/tbar[0]/btn[13]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").currentCellRow = 2
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/tbar[0]/btn[86]").press
session.findById("wnd[1]/tbar[0]/btn[13]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").currentCellRow = 3
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/tbar[0]/btn[86]").press
session.findById("wnd[1]/tbar[0]/btn[13]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").currentCellRow = 4
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/tbar[0]/btn[86]").press
session.findById("wnd[1]/tbar[0]/btn[13]").press