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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

KMKfan

Board Regular
Joined
Mar 8, 2004
Messages
106
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.
 

ramasterre

Active Member
Joined
Oct 5, 2004
Messages
253
Can someone tell me if I can refer to the workbook just as "ThisWorkbook"? so i can say ThisWorkbook.Activate ?
 

Forum statistics

Threads
1,147,674
Messages
5,742,541
Members
423,736
Latest member
dracula cyrus

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
Top