[RESOLVED] Left justified ControlButton caption
Excel question. Following code creates a CommandBar and several ControlButtons arranged vertically. Is there any way to make the ControlButton captions left justfied like in menus? I've played around adding spaces, Left$, Right$, and nothing seems to work. The captions are always centered within the width of the ControlButton. Ideas?
VB Code:
Sub DisplayToolBar()
'CommandBar caption is left justified
Dim cbar As CommandBar, cbctl As CommandBarButton, i As Integer
On Error Resume Next
Application.CommandBars("Custom Toolbar").Delete
Set cbar = Application.CommandBars.Add(Name:="Custom Toolbar", _
Position:=msoBarFloating, MenuBar:=False, Temporary:=True)
For i = 1 To 5
With cbar.Controls.Add(Type:=msoControlButton)
.Style = msoButtonCaption
'ControlButton captions are centered. How to make left/right justified????
.Caption = "test" & i & Left$("xyadafdadsfadf", i)
.OnAction = "Action"
.BeginGroup = True
.Width = 200
End With
Next i
With cbar
.Width = 200
.Enabled = True
.Protection = msoBarNoCustomize
.Visible = True
End With
End Sub
Edit: played around with spaces and Left$ enough to figure it out