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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Damon Ostrander

MrExcel MVP
Joined
Feb 17, 2002
Messages
4,239
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
 

Forum statistics

Threads
1,144,150
Messages
5,722,797
Members
422,459
Latest member
Chriselff

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