Macro not running

G

Grey Old Man

I have recorded a macro in an Excel 2002 template, created a Custom Menu
Item, and assigned the macro name to it.

When I open the template (which creates the file “name1.xlsâ€) and run the
macro from the Custom Menu Item, it fails with the message “name1.xls could
not be foundâ€.

However, when I run from ‘Tools | Macro | Run’ it works OK.

I'm confused. Any help would be appreciated.
 
D

Dave Peterson

First, if you really created a template workbook, then the workbook's that
created isn't name1.xls -- it won't have an extension until you save it to
disk. It should be just name1 or name11 or name12 or ...)

But I wouldn't put the macro in a template workbook. When you start the new
workbook based on this template, the customized menu macro will still point to
the .xls file (where you did your testing).

You could either have code that fixes the problem, but even easier would be to
uses an addin that creates the menu item and destroys it when you close excel.

Saved from a previous post:

For additions to the worksheet menu bar, I really like the way John Walkenbach
does it in his menumaker workbook:
http://j-walk.com/ss/excel/tips/tip53.htm

Here's how I do it when I want a toolbar:
http://www.contextures.com/xlToolbar02.html
(from Debra Dalgleish's site)

In xl2007, those toolbars and menu modifications will show up under the addins.

And if you use xl2007:

If you want to learn about modifying the ribbon, you can start at Ron de Bruin's
site:
http://www.rondebruin.nl/ribbon.htm
http://www.rondebruin.nl/qat.htm -- For macros for all workbooks (saved as an
addin)
or
http://www.rondebruin.nl/2007addin.htm

And Bob Phillips shows a way to use a wrapper so that it can work in both xl2003
and xl2007.
http://msmvps.com/blogs/xldynamic/archive/2010/03/27/deploy-me-simple.aspx
 

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