easy question about workbook naming

ramasterre

Active Member
Joined
Oct 5, 2004
Messages
253
Can someone tell me how references to workbooks are updated when the file is saved as a new name? I have a document that contains macros that must refer to that documents name. However, I use the document to create new (updated) documents weekly and I need the name of the document to save with the changes. As I have been building the macros for the document, I've noticed that the name changes are not always carried over to the code such that the macros cannot run because they are refering to the earlier version of the workbook. Is there a specific way that the name change must occur to carry over each time the workbook is renamed?


Thanks!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try:

Code:
Dim Document As WorkBook
Document = ActiveWorkbook.Name

Then every time you refer to the filename, you replace that with "Document"

I think that will solve your problem.
 
Upvote 0
Can someone tell me if I can refer to the workbook just as "ThisWorkbook"? so i can say ThisWorkbook.Activate ?
 
Upvote 0

Forum statistics

Threads
1,214,427
Messages
6,119,419
Members
448,895
Latest member
omarahmed1

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