.SaveAs doesn't initate 'Workbook_BeforeClose' ?

Lil2606

Board Regular
Joined
Jan 29, 2019
Messages
79
Hi all,

I am working on a macro that makes users click "Enable Content" mandatorily to access the workbook, works like a charm, except I have a macro which does a .SaveAs under a different name, and it automatically closes my original file, but doesn't initiate the "Workbook_BeforeClose" code I have in it.

Is there a way around this?

I do want to close the original doc, but have the "Workbook_BeforeClose" to run in it. I have to have my new workbook to be my active workbook, as the .SaveAs macro does a lot of things to it referring to a workbook object which equals my 'ActiveWorkbook'. (new wb is also an xlsm)

Can someone help me with this?

Thanks!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
The original file does not close, you've simply changed the name (and possibly location), hence the beforeclose does not trigger.
Why not put the BeforeClose code into a standard module & then call it from both routines?
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,892
Messages
6,175,236
Members
452,621
Latest member
Laura_PinksBTHFT

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