Save and close an active workbook with VBA

Kristina96

New Member
Joined
Sep 30, 2019
Messages
33
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
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

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