PDA

View Full Version : Solved: The Macro "macroname" Cannot Be Found



reemoe
08-15-2007, 08:13 AM
I have an Excel document with a macro that opens another spreadsheet that contains a command button, which in turn runs a macro when clicked.

I am trying to create a second version of these two spreadsheets with slight modifications.

The first macro runs OK, but I receive the following when Excel attempts to run the second macro: Run-time error '1004': The macro "full name here including the name and location of file" cannot be found.

If I then click 'Debug', it takes me to a line in Visual Basic highlighted in yellow: Application.Run "ABC.xls!macroname"

How do I get it to refer to the macro properly?
By the way, this is in Excel 2000.
Thanks!

rory
08-15-2007, 08:30 AM
Are there any spaces in the workbook name?

Bob Phillips
08-15-2007, 08:35 AM
Is the sub public, no parameters?

reemoe
08-15-2007, 08:37 AM
No, no spaces. These are macros that worked, but when I saved the spreadsheets to another name (e.g. from ABC.xls to ABC-2.xls), I now get the error message.

The only change to the VBA code was to update the file names--(if something referenced a file like ABC.xls, I made it ABC-2, etc).

rory
08-15-2007, 08:46 AM
Is the workbook in question open? Are you including the full path to the file in the Application.Run statement? Are you sure there are no typos in the run statement? Have you checked that the module containing the macro has not been given the same name as the macro? (I assume the macro is in a normal module, not in a worksheet module or the ThisWorkbook module)

reemoe
08-15-2007, 09:55 AM
I'm fairly new to macros, so I may need some extra help here.

I'm not sure what you mean by the sub being public, no parameters. Can you please explain another way?

Yes, this is a normal module. How do you check whether the module with the macro has been given the same name as the macro?

Bob Phillips
08-15-2007, 10:05 AM
It is public if it isn't private. So, if the Sub in the procedure signatire is not preceded by Private, then it is Public.

It will have arguments if there is anything in between the () in the procedures signature.

What is the name of the macro? The module name can be found by looking in the properties window (F4) when the macro is selected.

Bob Phillips
08-15-2007, 10:05 AM
Why not post the 2 workbooks?

reemoe
08-15-2007, 11:44 AM
Yes, it is public.

The name of the macro (under Assign Macro...) is movetodlftoday, although in the properties window, it shows Module8.

Bob Phillips
08-15-2007, 11:54 AM
NOthing obvious then. Can you post the workbooks?

reemoe
08-15-2007, 01:52 PM
Attached is the first workbook involved. The first two command buttons at the top work. It's the third one (titled Move to DLF) that is causing the error.

Looks like I'll have to send the second workbook in a separate post.

reemoe
08-15-2007, 01:55 PM
Here is the second workbook (the one that includes a command button referred to in the problematic macro in the first workbook).

Thanks for reviewing these!:hi:

Bob Phillips
08-15-2007, 02:42 PM
I got this to work



Application.Run "'DLF-B.xls'!move2dlfToday"


It seems that hyphen needs singlw quotes like spaces.

reemoe
08-16-2007, 08:47 AM
Great news, xld!!!

Thanks a bunch!