ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Why does this mouse menu call a sub from another workbook? (https://www.excelbanter.com/excel-programming/371105-why-does-mouse-menu-call-sub-another-workbook.html)

Hermac

Why does this mouse menu call a sub from another workbook?
 
Hello,

I've been on this problem for more than a day now and I can't figure it
out.
I have a worksheet embedded chart which, on right click, shows a
modified mouse menu, which in turn allows to fire a sub called
"MaakGraf". Like this

Set MenuItem =
Application.CommandBars("Object/plot").Controls.Add(Type:=msoControlButton)
With MenuItem
.Caption = "Maak deze Grafiek"
.OnAction = "MaakGraf"
End With

It worked perfectly until yesterday. But since then, when clicking the
"Maak deze Grafiek" option, I get a prompt to enable or disable the
macro's of an OTHER workbook, to wich there is absolutely no link
although this other workbook is very similar to the active one and has
a sub with the same name. If enabled, the other workbook is opened.

If called with F5 or via the Extra-Macro menu, the sub perfectly refers
to the intended sub in the active workbook.

What am I overlooking here ?

Thank you very much for any help.
Herman


Dave Peterson

Why does this mouse menu call a sub from another workbook?
 
The button is still assigned to the MaakGraf in the other workbook.

I would delete either the "maak deze grafiek" item from the Object/plot
commandbar before building it or even delete the whole object/plot commandbar
before creating that one.



Hermac wrote:

Hello,

I've been on this problem for more than a day now and I can't figure it
out.
I have a worksheet embedded chart which, on right click, shows a
modified mouse menu, which in turn allows to fire a sub called
"MaakGraf". Like this

Set MenuItem =
Application.CommandBars("Object/plot").Controls.Add(Type:=msoControlButton)
With MenuItem
.Caption = "Maak deze Grafiek"
.OnAction = "MaakGraf"
End With

It worked perfectly until yesterday. But since then, when clicking the
"Maak deze Grafiek" option, I get a prompt to enable or disable the
macro's of an OTHER workbook, to wich there is absolutely no link
although this other workbook is very similar to the active one and has
a sub with the same name. If enabled, the other workbook is opened.

If called with F5 or via the Extra-Macro menu, the sub perfectly refers
to the intended sub in the active workbook.

What am I overlooking here ?

Thank you very much for any help.
Herman


--

Dave Peterson

Hermac

Why does this mouse menu call a sub from another workbook?
 
Thanks, Dave. That does it indeed. I learned something new here.
Herman



All times are GMT +1. The time now is 10:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com