ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBE Custom menuitem not calling OnAction macro (https://www.excelbanter.com/excel-programming/303941-vbe-custom-menuitem-not-calling-onaction-macro.html)

R Avery

VBE Custom menuitem not calling OnAction macro
 
I am working with the example provided in:

http://msdn.microsoft.com/library/de...ce07042002.asp


I have created a custom button programmatically and assigned it a macro
using its OnAction property. I have checked the OnAction property to
ensure that it got set properly.

I tried setting this property to "MyTestSub", "Personal.xls!MyTestSub",
"Module1!MyTestSub", but none of them work. No error occurs when i
click the button; nothing happens at all. How do I get a VBE menuitem
to call a macro that I have in my Personal.xls? (Note: I also tried
this same thing in Word, and met with the same results).



Sub MyTestSub
MsgBox "Test"
End Sub

Bob Flanagan

VBE Custom menuitem not calling OnAction macro
 
It sounds like you have macro protection set to high, and have opened the
workbook since you put a macro in it. Microsoft does not warn you that
macros are disabled when protection is set to high, nor tell you that macros
you try to run are disabled.

Try setting protection to medium and closing and re-opening the workbook.

Bob Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"R Avery" wrote in message
...
I am working with the example provided in:


http://msdn.microsoft.com/library/de...ce07042002.asp


I have created a custom button programmatically and assigned it a macro
using its OnAction property. I have checked the OnAction property to
ensure that it got set properly.

I tried setting this property to "MyTestSub", "Personal.xls!MyTestSub",
"Module1!MyTestSub", but none of them work. No error occurs when i
click the button; nothing happens at all. How do I get a VBE menuitem
to call a macro that I have in my Personal.xls? (Note: I also tried
this same thing in Word, and met with the same results).



Sub MyTestSub
MsgBox "Test"
End Sub




R Avery

VBE Custom menuitem not calling OnAction macro
 
I have done some research and found this:

http://groups.google.com/groups?hl=e...com%26rnum%3D1

It appears that you need to create a class that implements the office
menuitem click event in order for it to fire. Simply setting the
OnAction property does nothing.

Norman Jones

VBE Custom menuitem not calling OnAction macro
 
Hi,

See Chip Pearson's VBECmdHandler class:

http://www.cpearson.com/excel/vbemenus.htm

---
Regards,
Norman



"R Avery" wrote in message
...
I have done some research and found this:


http://groups.google.com/groups?hl=e...com%26rnum%3D1

It appears that you need to create a class that implements the office
menuitem click event in order for it to fire. Simply setting the
OnAction property does nothing.




R Avery

VBE Custom menuitem not calling OnAction macro
 
Thanks!


All times are GMT +1. The time now is 01:22 AM.

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