Close and Save another workbook doesn't work?

sanantonio

Board Regular
Joined
Oct 26, 2021
Messages
124
Office Version
  1. 365
Platform
  1. 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.

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?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,214,385
Messages
6,119,208
Members
448,874
Latest member
b1step2far

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top