You should put the macro in a regular code module.
ThisWorkbook is a workbook class module, which means that workbook event
procedures will by default call procedures within the class. When you
call a class procedure from outside the class (e.g., from a menu's
OnAction event), you need to fully qualify the reference, e.g.,
.OnAction ="Workbook1.xls!ThisWorkbook.foo"
From a menu item, you don't need to include the class module:
.OnAction = "Workbook1.xls!bar"
See
http://cpearson.com/excel/codemods.htm
In article ,
"Ed" wrote:
I create a menu with two items in the list. The menu is created with a
Workbook_Open macro in the ThisWorkbook module. The macro called by the
menu item's OnAction also resides in the ThisWorkbook module. But when
selecting that menu item, I get the error "Macro 'Workbook!Macro' does not
exist." I call the same macro within the code of a
Workbook_SheetSelectionChange macro, again in the ThisWorkbook module, and
it works fine. What am I missing?