Otto,
I usually use the Parameter property of a CommandBarControl to pass
information to the OnAction procedure. For example, when you create the
control, use something like
Ctrl.Parameter = "Some Text"
Ctrl.OnAction = "'" & ThisWorkbook.Name & "'!ProcName"
Then in the OnAction procedure ProcName,
Sub ProcName()
If Not Application.CommandBars.ActionControl Is Nothing Then
MsgBox Application.CommandBars.ActionControl.Parameter
End If
End Sub
Note that the OnAction property can set the Parameter value of another
control, so you can pass context-sensitive information between command bar
buttons. For example, the OnAction procedure of Button1 can put information
in the Parameter property of Button2, and then Button2 can run code that
depends on whether Button1 has previous been clicked.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
"Otto Moehrbach" <(E-Mail Removed)> wrote in message
news:eIL2$(E-Mail Removed)...
> Bob
> That never occurred to me. That's a good idea.
> Can I ask you another related question?
> In the macro call for a menu item, I want to pass a string value.
> Right now, the macro contains only a MsgBox telling me the passed string.
> The problem: The MsgBox fires twice (click OK and the MsgBox appears
> again).
> If I do not pass a value and change the MsgBox to simply "Hello", the
> MsgBox fires only once.
> Is there a rationale for this? Thanks for your time. Otto
> "Bob Phillips" <(E-Mail Removed)> wrote in message
> news:egBQ%(E-Mail Removed)...
>> You could always add the menu in the Workbook_Activate event rather than
>> Workbook_Open, and remove it in the Workbook_Deactivate. Other workbooks
>> won't even see it in that case.
>>
>> --
>> ---
>> HTH
>>
>> Bob
>>
>> (there's no email, no snail mail, but somewhere should be gmail in my
>> addy)
>>
>>
>>
>> "Otto Moehrbach" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Excel XP & Win XP
>>> I have a user created menu that I built with John Walkenbach's easy
>>> menu maker. The menu has about 30 items. Of course, the menu is
>>> available to any open workbook besides the also-open intended workbook.
>>> I know how to place code in each macro for each menu item to check
>>> the active workbook name. My question is this: Can I prevent access or
>>> pop up a MsgBox (and cancel) when the primary menu item is accessed with
>>> the wrong workbook active, rather than do the same thing for each of the
>>> 30 menu item macros? Thanks for your time. Otto
>>>
>>
>>
>
>