Olá Umur,
Obrigado pela sua resposta.
O comando que abre a caixa de diálogo SALVAR COMO é:
session.findById("wnd[0]/mbar/menu[0]/menu[1]/menu[1]").Select
...mas estou recebendo um erro na linha:
Wshell.Run "C:\Nova pasta\DataLoad.vbs " & NomeArquivo, 1, False
Meu código agora se parece com isso (todo o meu código junto com a configuração do Userform):
Private Sub CommandButton1_Click()
Dim MojaData
MojaData = ComboBox2.Value
Dim Companycode
Companycode = ComboBox1.Value
Dim Depreciation_area
Depreciation_area = ComboBox3.Value
If Not IsObject(Application1) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Application1 = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = Application1.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 Application1, "on"
End If
Dim sbar As String
sbar = session.findById("wnd[0]/sbar").Text
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/n s_alr_87011990"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtBUKRS-LOW").Text = Companycode
session.findById("wnd[0]/usr/ctxtSO_ANLKL-LOW").Text = ""
session.findById("wnd[0]/usr/ctxtBERDATUM").Text = MojaData
session.findById("wnd[0]/usr/ctxtBEREICH1").Text = Depreciation_area
session.findById("wnd[0]/usr/ctxtSRTVR").Text = "0003"
session.findById("wnd[0]/usr/radSUMMB").SetFocus
session.findById("wnd[0]/tbar[1]/btn[8]").press
NomeArquivo = "C:\Nova pasta\Notificações.txt"
Wshell.Run "C:\Nova pasta\DataLoad.vbs " & NomeArquivo, 1, False
session.findById("wnd[0]/mbar/menu[0]/menu[1]/menu[1]").Select
Dim FileNam2
Set Wshell = CreateObject("WScript.Shell")
Do
bWindowFound = Wshell.AppActivate("Salvar como")
WScript.Sleep 1000
Loop Until bWindowFound
bWindowFound = Wshell.AppActivate("Salvar como")
If (bWindowFound) Then
Wshell.AppActivate "Salvar como"
WScript.Sleep 100
Wshell.SendKeys "{TAB}"
Wshell.SendKeys "{TAB}"
Wshell.SendKeys "{TAB}"
Wshell.SendKeys "{TAB}"
Wshell.SendKeys "{TAB}"
WScript.Sleep 100
FileNam2 = WScript.Arguments.Item(0)
Wshell.SendKeys FileNam2
WScript.Sleep 100
Wshell.SendKeys "{ENTER}"
WScript.Sleep 100
Fim Se
Fim Sub
Private Sub UserForm_Initialize()
'Esvaziar caixa de código de empresa
ComboBox1.Clear
'Preencher caixa de código de empresa
With ComboBox1
.AddItem "BE10"
.AddItem "BE11"
.AddItem "BE12"
.AddItem "BE14"
ComboBox1.Value = "BE10"
End With
'Esvaziar caixa de saldo de ativos
ComboBox2.Clear
'Preencher caixa de saldo de ativos
With ComboBox2
.AddItem "31.01.2014"
.AddItem "28.02.2014"
.AddItem "31.03.2014"
.AddItem "30.04.2014"
.AddItem "31.05.2014"
.AddItem "30.06.2014"
.AddItem "31.07.2014"
.AddItem "31.07.2014"
.AddItem "31.08.2014"
.AddItem "30.09.2014"
.AddItem "31.10.2014"
.AddItem "30.11.2014"
.AddItem "31.12.2014"