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

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

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,181,993
Messages
5,933,145
Members
436,881
Latest member
CMScons

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