View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default AddIn Name Resolution

I tested your suggestion and I get a message that the sub MySub can't be
found. This makes sense because he has the MySub macro in the ThisWorkbook
Module.

William, I think your solution is to use unique names.

instead of MySub

MyAddinName835_MySub

Whether this is a bug or not would depend on MS's design for evaluating what
macro to run. It the workbook version of William is not the active
workbook, then it runs fine. So it looks like a situation similar to where
a local variable screens out a global variabe. Because of the way the macro
is assigned, I don't think there is a way to differentiate like you can
with the variables. So using the unique name would be the answer.

--
Regards,
Tom Ogilvy



"Jim Cone" wrote in message
...
William,

Make the change exactly as I show. Also, to emphasize,
the quote marks should be exactly as I show.

"MySub.xla!MySub" (with the quote marks) should
also work, but if you change the add-in name then it will fail.

Jim Cone


"William Barnes"
wrote in message

Thanks for your prompt response, Jim.
Your suggestion looked promising, but it didn't seem to affect things. Let
me be certain that I changed things as you intended. In the AddIn
MakeToolbar() Sub, I changed
.OnAction = "ThisWorkbook.MySub"
to
.OnAction = "MySub.xla!ThisWorkbook.MySub"
I then saved the AddIn, unloaded it, and after reloading it Excel still
executed the Workbook version. I even tried restarting Excel without
success.


"Jim Cone" wrote in message
...
William,

Try changing...
.OnAction = "ThisWorkbook.MySub"
To...
.OnAction = ThisWorkbook.Name & "!MySub"

Regards,
Jim Cone
San Francisco, USA