Renaming macros...

J

jmdaniel

Why can't I rename a file that has macros in it, then change all references
in the code to the new file name, and get the macro to work? A snippet of my
code:

Windows("nih_payment").Activate
ActiveWorkbook.Close
Application.DisplayAlerts = True
Windows("NIH NonProduction Spend Macro.xls").Activate
Application.Run "NIH NonProduction Spend Macro.xls!Macro1"
Range("A1").Select
Selection.AutoFilter

The macro was built by a summer intern, who was short on imagination, so I
replaced his name for the file, "Macro2", with a more descriptive one, "NIH
NonProduction Spend Macro". The only bad thing is that this macro now will
only run if it is run by itself, not called out in the midst of another
macro. If I try to do the latter, all I get is the error message:

The macro 'NIH NonProduction Spend Macro.xls!'Macro1' cannot be found.

There are no Links to reset; that action is grayed out. Kind of a head
scratcher...
 
J

JC

Do you have a lowercase mod at the end of the name? Also
try removing the spaces.
(NIHNonProductionSpendMacromod) Not sure if that's your
problem, but it may be.
JC
-----Original Message-----
Why can't I rename a file that has macros in it, then change all references
in the code to the new file name, and get the macro to work? A snippet of my
code:

Windows("nih_payment").Activate
ActiveWorkbook.Close
Application.DisplayAlerts = True
Windows("NIH NonProduction Spend Macro.xls").Activate
Application.Run "NIH NonProduction Spend Macro.xls! Macro1"
Range("A1").Select
Selection.AutoFilter

The macro was built by a summer intern, who was short on imagination, so I
replaced his name for the file, "Macro2", with a more descriptive one, "NIH
NonProduction Spend Macro". The only bad thing is that this macro now will
only run if it is run by itself, not called out in the midst of another
macro. If I try to do the latter, all I get is the error message:

The macro 'NIH NonProduction Spend
Macro.xls!'Macro1' cannot be found.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top