ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find OnAction property (https://www.excelbanter.com/excel-programming/283251-find-onaction-property.html)

Kemosabe

Find OnAction property
 
How do I determine the value of the OnAction property of an existing
(built-in or custom) commandbar item? I would like to do something
like this:

Public Sub ShowOnAction()

MsgBox Application.CommandBars("File").Controls("Print
Preview").OnAction

End Sub

This sub does not fail, but it returns nothing.

I would also like to intercept the subroutine called by the OnAction
property and replace it like in this Word procedu

http://www.mvps.org/word/FAQs/Macros...tSavePrint.htm

Can that be done in Excel?


Tom Ogilvy

Find OnAction property
 
Your code should work for a custom commandbar item that has been assigned an
onaction macro. Builtin controls don't execute macros, so they don't have
anything assigned to the onaction property (although you can assign a macro
to the onaction property to override normal behavior). There isn't any
intercepting in Excel beyond what I have stated.

In excel you also have BeforeSave, BeforeClose and BeforePrint events at the
workbook and application level if you want to instantiate application level
events.

--
Regards,
Tom Ogilvy

"Kemosabe" wrote in message
...
How do I determine the value of the OnAction property of an existing
(built-in or custom) commandbar item? I would like to do something
like this:

Public Sub ShowOnAction()

MsgBox Application.CommandBars("File").Controls("Print
Preview").OnAction

End Sub

This sub does not fail, but it returns nothing.

I would also like to intercept the subroutine called by the OnAction
property and replace it like in this Word procedu

http://www.mvps.org/word/FAQs/Macros...tSavePrint.htm

Can that be done in Excel?





All times are GMT +1. The time now is 09:43 AM.

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