Remove macro from backup excel document

L

Legacy 260385

Guest
I have this macro currently running on an original excel document
Private Sub Workbook_Open()Dim fname
fname = "C:\backup\Economics Tracker - " & Format(Now, "dd mmm yy hh mm AM/PM") & ".xlsm"
ThisWorkbook.SaveCopyAs Filename:=fname


Sheets("Menu").Activate
End Sub

Which creates a backup of the document each time the document is opened;
I was wondering, is it possible to remove that particular macro from the backup as opposed to saving the backup as .xlsx?
I don't want to be able to open a backup and the backup makes a backup

That particular macro is running on the main workbook.

Thank You!
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Maybe:
Code:
Private Sub Workbook_Open()
Dim fname
If InStr(ThisWorkbook.FullName, "backup") > 0 Then Exit Sub
fname = "C:\backup\Economics Tracker - " & Format(Now, "dd mmm yy hh mm AM/PM") & ".xlsm"
ThisWorkbook.SaveCopyAs Filename:=fname
Sheets("Menu").Activate
End Sub
 
Upvote 0
(To JoeMo) Thanks!! That worked perfectly! I added the 'Sheets("Menu").Activate' right after 'Dim fname' so it always loads the menu page on the backup also :)
 
Last edited by a moderator:
Upvote 0
(To Artik) Oh, I previously used SaveAs but the problem is that it instantly loaded the backup file after saving instead of reverting to the original file
 
Upvote 0
Thanks!! That worked perfectly! I added the 'Sheets("Menu").Activate' right after 'Dim fname' so it always loads the menu page on the backup also :)
Which post is "That"? You can refer to a specific post easily if you use 'Reply With Quote' at the bottom of the specific post.
 
Upvote 0
Which post is "That"? You can refer to a specific post easily if you use 'Reply With Quote' at the bottom of the specific post.
Sorry, it was to you; fairly new to using forums xD But thanks, I will use that in the future :)
 
Upvote 0

Forum statistics

Threads
1,214,845
Messages
6,121,902
Members
449,053
Latest member
Guy Boot

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