Hi experts, I need your help. My code stops running when save as dialogue box appears. Does anybody know how can it go on? It happens on line "session.findById("wnd[0]/tbar[1]/btn[43]").press"
Please I would be thankful for you help me.
Public Sub Buscar_ZGLPM051()
'Login no SAP
Set SapGuiAuto = GetObject("SAPGUI") 'Obtenha o objeto SAP GUI Scripting
Set SAPApp = SapGuiAuto.GetScriptingEngine 'Obter o SAP GUI atualmente em execução
Set SAPCon = SAPApp.Children(0) 'Obter o primeiro sistema que está conectado
Set session = SAPCon.Children(0) 'Obter a primeira sessão (janela) nessa conexão
'inicia seção ZGLPM051
session.StartTransaction "ZGLPM051"
session.findById("wnd[0]").maximize
On Error Resume Next
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").unselectAll
If Err.Number <> 0 Then
End If
'execução dos comandos "script" gerado pelo SAP
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").expandNode "F00039"
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selectedNode = "F00018"
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").topNode = "Favo"
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00018"
session.findById("wnd[0]/tbar[1]/btn[17]").press
session.findById("wnd[1]/tbar[0]/btn[8]").press
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/tbar[1]/btn[33]").press
session.findById("wnd[1]/usr/lbl[1,19]").SetFocus
session.findById("wnd[1]/usr/lbl[1,19]").caretPosition = 7
session.findById("wnd[1]").sendVKey 2
session.findById("wnd[0]/tbar[1]/btn[43]").press
'Here still follow SAP GUI commands.
session.findById("wnd[1]/usr/radRB_OTHERS").SetFocus
session.findById("wnd[1]/usr/radRB_OTHERS").Select
session.findById("wnd[1]/usr/cmbG_LISTBOX").Key = "08"
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[0,0]").Select
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
'Here are specific Excel - commands that one can not record. This one needs to know.
Set xclapp = GetObject(, "Excel.Application")
xclapp.DisplayAlerts = False
Set xclwbk = xclapp.Workbooks.Item("Planilha em Basis (1)")
xclapp.ActiveWorkbook.SaveAs ("C:\tmp\myWorkbook.xlsx")
xclapp.ActiveWorkbook.Close
Set xclwbk = Nothing
xclapp.DisplayAlerts = True
Set xclapp = Nothing
Range("A2").Select
End Sub