VBA code to locate the command bar number the printer button is on
Hi,
I used Norman's code and developed it a bit further.
It saves the Index of the Print (and checks it's not Print Preview)
into
a variable called intIndex.
I tested with Print-control in different positions in the
'Standard'-cmdBar
and it works.
***
Public Sub TesterA001()
Dim Ctrl As Office.CommandBarControl
Dim intIndex As Integer
For Each Ctrl In Application.CommandBars("Standard").Controls
If Left(Ctrl.Caption, 5) = "Print" Then
If Left(Ctrl.Caption, 7) < "Print P" Then
intIndex = Ctrl.Index
End If
End If
Next Ctrl
End Sub
***
Hope this solves your problem
JK
|