ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Common routine for many menu buttons (https://www.excelbanter.com/excel-programming/396811-common-routine-many-menu-buttons.html)

Dave D-C[_3_]

Common routine for many menu buttons
 
Hello,
I have 20 ControlButtons on a CommandBar, and the actions are similar,
but a parameter is needed. So I could brute force with 20 routines:
CBControl1.OnAction = "Do1"
CBControl2.OnAction = "Do2"
etc.
Sub Do1()
Call DoAll(1) ' common routine
End Sub
Sub Do2()
Call DoAll(2) ' common routine
End Sub
etc.

Is there a way for a DoAll routine to get the tag or the parameter
from the menu button that was pushed? How does one use
CBControl.Parameter?

TIA, Dave


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Jon Peltier

Common routine for many menu buttons
 
Try this technique from John Walkenbach's site:

http://www.j-walk.com/ss/excel/tips/tip44.htm

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Dave D-C" wrote in message
...
Hello,
I have 20 ControlButtons on a CommandBar, and the actions are similar,
but a parameter is needed. So I could brute force with 20 routines:
CBControl1.OnAction = "Do1"
CBControl2.OnAction = "Do2"
etc.
Sub Do1()
Call DoAll(1) ' common routine
End Sub
Sub Do2()
Call DoAll(2) ' common routine
End Sub
etc.

Is there a way for a DoAll routine to get the tag or the parameter
from the menu button that was pushed? How does one use
CBControl.Parameter?

TIA, Dave


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption
=----





All times are GMT +1. The time now is 02:06 PM.

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