Save and close an active workbook with VBA

Kristina96

New Member
Joined
Sep 30, 2019
Messages
28
Hello everyone,

I have a macro that opens another excel file, makeschanges in that file and should then save and close the document.
Currently I am using this line of code for saving and closing the document:

Code:
WB2.Close SaveChanges:=True
By using this code it is doing save as meaning it opens an additional window asking where to save the new document. I just want to save the changes to the exisiting document. In other words a simple "Save" instead of "Save As". How do I have to change the code?

Thank you and best regards,
Kristina
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,440
Office Version
365
Platform
Windows
That line of code is using Save, not SaveAs. If you are being asked for a filename it suggests that the workbook is Read Only.
 

Forum statistics

Threads
1,082,586
Messages
5,366,476
Members
400,892
Latest member
lamarh755

Some videos you may like

This Week's Hot Topics

Top