sanantonio
Board Regular
- Joined
- Oct 26, 2021
- Messages
- 124
- Office Version
- 365
- Platform
- Windows
Hi All,
Happy holidays!
Was hoping someone could help me out with this code.
The first part of the code is where I have SAP exporting and auto saving a file. When SAP exports and saves a file it also opens it automatically. So I have put in an "Application.wait" code to wait for the file to open before attempting to close it, then coming back to my original excel and refreshing all. It is the code in red that doesn't work. I just get a debug.
What I need to do is just wait for the export to open, the "ZMMX118.XLSX", then close it without saving, return to the macro workbook where this code lives and refresh all.
Am I missing something obvious?
Happy holidays!
Was hoping someone could help me out with this code.
The first part of the code is where I have SAP exporting and auto saving a file. When SAP exports and saves a file it also opens it automatically. So I have put in an "Application.wait" code to wait for the file to open before attempting to close it, then coming back to my original excel and refreshing all. It is the code in red that doesn't work. I just get a debug.
VBA Code:
session.findById("wnd[1]/usr/ctxtDY_PATH").Text = "J:\filepath"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").Text = "ZMMX118.XLSX"
session.findById("wnd[1]/usr/ctxtDY_PATH").SetFocus
session.findById("wnd[1]/usr/ctxtDY_PATH").caretPosition = 102
session.findById("wnd[1]/tbar[0]/btn[11]").press
session.findById("wnd[0]/tbar[0]/btn[12]").press
session.findById("wnd[0]/tbar[0]/btn[12]").press
Application.Wait (Now + TimeValue("0:01:00")) 'Waiting for ZMMX118 export to open
Application.DisplayAlerts = False
Workbooks("ZMMX118.xlsx").Close SaveChanges:=False 'Closes the export without saving
ActiveWorkbook.RefreshAll 'returns to macro enabled workbook where this code lives and refreshes all
What I need to do is just wait for the export to open, the "ZMMX118.XLSX", then close it without saving, return to the macro workbook where this code lives and refresh all.
Am I missing something obvious?