macro problem

tandrea

New Member
Joined
Apr 24, 2002
Messages
27
I have a master workbook that contains this macro. When I rename the workbook, the macro doesn't work because the name of the workbook changes. Is there something I can substitute in the macro instead of "Ovations Weekly Field Service Production Sheet Master.xls" that will work in a workbook no matter what it is named?

Thank you!


Application.Run "'Ovations Weekly Field Service Production Sheet Master.xls'!unprotect"
Windows("Ovations Weekly Field Service Production Sheet Master.xls").Activate
Application.Run "'Ovations Weekly Field Service Production Sheet Master.xls'!OvationsHospital"
Windows("Ovations Weekly Field Service Production Sheet Master.xls").Activate
Application.Run "'Ovations Weekly Field Service Production Sheet Master.xls'!protect"
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi tandrea,

Unless a macro resides in a different workbook than the calling code, the run command is not needed, in which case the following code should be equivalent to your code except that it refers to the macros in the ThisWorkbook object (NOT the macros in the ThisWorkbook event code module):

unprotect
'(probably is already active, but anyway...)
ThisWorkbook.Activate
OvationsHospital
'(re-activation only required if OvationsHospital changes the active workbook)
ThisWorkbook.Activate
protect
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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