Sub test()
' открытие сап
If Not IsObject(Appl) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Appl = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = Appl.Children(0)
End If
If Not IsObject(sess) Then
Set sess = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject sess, "on"
WScript.ConnectObject Appl, "on"
End If
' составление таблиц и открытие ее.
sess.findById("wnd[0]").Maximize
sess.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00209"
sess.findById("wnd[0]/tbar[1]/btn[17]").press
sess.findById("wnd[1]/usr/txtENAME-LOW").Text = "safonova-o"
sess.findById("wnd[1]/usr/txtENAME-LOW").SetFocus
sess.findById("wnd[1]/usr/txtENAME-LOW").caretPosition = 10
sess.findById("wnd[1]/tbar[0]/btn[8]").press
sess.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").setCurrentCell 1, "TEXT"
sess.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").selectedRows = "1"
sess.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").doubleClickCurrentCell
sess.findById("wnd[0]/usr/tabsTABSTRIP_ORDER_CRITERIA/tabpS0S_TAB1/ssub%_SUBSCREEN_ORDER_CRITERIA:/BSHS/DM_SHP_MTRSTA:1010/ctxtP_VARI").Text = "/LYSIKOV"
sess.findById("wnd[0]/usr/tabsTABSTRIP_ORDER_CRITERIA/tabpS0S_TAB1/ssub%_SUBSCREEN_ORDER_CRITERIA:/BSHS/DM_SHP_MTRSTA:1010/ctxtP_VARI").SetFocus
sess.findById("wnd[0]/usr/tabsTABSTRIP_ORDER_CRITERIA/tabpS0S_TAB1/ssub%_SUBSCREEN_ORDER_CRITERIA:/BSHS/DM_SHP_MTRSTA:1010/ctxtP_VARI").caretPosition = 8
sess.findById("wnd[0]/tbar[1]/btn[8]").press
sess.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").setCurrentCell 2, "DPREG"
sess.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectedRows = "2"
sess.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").contextMenu
sess.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectContextMenuItem "&XXL"
sess.findById("wnd[1]/tbar[0]/btn[0]").press
sess.findById("wnd[1]/usr/ctxtDY_FILENAME").Text = "SHIPMENT.XLSX"
sess.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 8
sess.findById("wnd[1]/tbar[0]/btn[11]").press
Call TT
End Sub
' сохранение открывшегося файла .XLSX
Sub TT()
Dim xlWb
Set xlWb = GetObject(, "Excel.Application")
xlWb.Parent.Windows(1).Visible = True
xlWb.Application.displayalerts = False
xlWb.Application.activeworkbook.SaveAs FileName:="\\bykna001\FREDIRECT$\Lysikov\Desktop\ëèñò ïîäáîðГ*\SHIPMENT2.XLSX", FileFormat:=51
xlWb.Quit
End Sub