I have some VBA code that exports SAP data to a .XLSX file, then imports this file into excel. After the file is imported, I have code that performs many other actions (eg p
My solution here if anybody still needs help. I created a sub in order to kill a lot of files i export. thx scriptman ...
.findById("wnd[0]/mbar/menu[0]/menu[10]/menu[3]/menu[1]").Select
.findById("wnd[1]/usr/ctxtDY_PATH").Text = "C:\Informe\"
.findById("wnd[1]/usr/ctxtDY_FILENAME").Text = "tcurr.xlsx"
.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 10
.findById("wnd[1]/tbar[0]/btn[11]").press
End With
'Application.Wait Now + TimeValue("00:00:02")
Call Esperar("tcurr.XLSX")
Public Sub Esperar(Optional ByVal archivo As String)
On Error Resume Next
Set Wshell = CreateObject("WScript.Shell")
Do
Err.Clear
Set xclapp = GetObject(, "Excel.Application")
If Err.Number = 0 Then Exit Do
DoEvents '---> This do the trick in VB7
'msgbox "Wait for Excel session"
wscript.Sleep 2000
Loop
Do
Err.Clear
Set xclwbk = xclapp.Workbooks.Item(archivo)
If Err.Number = 0 Then Exit Do
DoEvents
'msgbox "Wait for SAP workbook"
wscript.Sleep 2000 Loop
On Error GoTo 0
Set xclsheet = xclwbk.Worksheets(1)
xclapp.Visible = True
xclapp.DisplayAlerts = False
xclapp.ActiveWorkbook.Close
Set xclwbk = Nothing
Set xclsheet = Nothing
End Sub