Re: VBA code to locate the command bar number the printer button is on
Tech-Archive recommends: Fix windows errors by optimizing your registry
Hi Mike,
The following version restricts operation to visible commandbars:
'=============>>
Public Sub TesterA001()
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=4)
With Ctrl
If .Parent.Visible Then
MsgBox "Commandbar: " & .Parent.Name _
& " position = " & .Index
End If
End With
Next Ctrl
End Sub
'<<=============
---
Regards,
Norman
"Norman Jones" <normanjones@xxxxxxxxxxxxxxxxxxx> wrote in message
news:OKOArpsJGHA.648@xxxxxxxxxxxxxxxxxxxxxxx
> Hi Mike,
>
> As a starting point, try:
>
> '=============>>
> Public Sub TesterA001()
> Dim Ctrl As Office.CommandBarControl
> For Each Ctrl In Application.CommandBars.FindControls(ID:=4)
> MsgBox "Commandbar: " & Ctrl.Parent.Name _
> & " position = " &
> Ctrl.Index
> Next Ctrl
> End Sub
> '<<=============
>
>
> ---
> Regards,
> Norman
>
>
>
> "mikeburg" <mikeburg.22ixza_1138753201.1653@xxxxxxxxxxxxxxxxxxxxx> wrote
> in message news:mikeburg.22ixza_1138753201.1653@xxxxxxxxxxxxxxxxxxxxxxxx
>>
>> What would be the simplest VBA code to locate the command bar number
>> that the printer command button is on & put the number into a
>> variable.
>>
>> I am trying to add two command buttons immediately after the printer
>> command button but it's on different command bars from computer to
>> computer.
>>
>> For example, it may be on command bar #3 on one computer but on #4 of
>> another computer.
>>
>> Thanks. I dream of a day when I would be half as good at VBA as you
>> guys. Thanks, mikeburg
>>
>>
>> --
>> mikeburg
>> ------------------------------------------------------------------------
>> mikeburg's Profile:
>> http://www.excelforum.com/member.php?action=getinfo&userid=24581
>> View this thread:
>> http://www.excelforum.com/showthread.php?threadid=507006
>>
>
>
.