Results 1 to 1 of 1

Thread: [RESOLVED] Left justified ControlButton caption

Threaded View

  1. #1

    Thread Starter
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    [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:
    1. Sub DisplayToolBar()
    2.     'CommandBar caption is left justified
    3.     Dim cbar As CommandBar, cbctl As CommandBarButton, i As Integer
    4.     On Error Resume Next
    5.     Application.CommandBars("Custom Toolbar").Delete
    6.     Set cbar = Application.CommandBars.Add(Name:="Custom Toolbar", _
    7.         Position:=msoBarFloating, MenuBar:=False, Temporary:=True)
    8.     For i = 1 To 5
    9.         With cbar.Controls.Add(Type:=msoControlButton)
    10.             .Style = msoButtonCaption
    11.             'ControlButton captions are centered.  How to make left/right justified????
    12.             .Caption = "test" & i & Left$("xyadafdadsfadf", i)
    13.             .OnAction = "Action"
    14.             .BeginGroup = True
    15.             .Width = 200
    16.         End With
    17.     Next i
    18.     With cbar
    19.         .Width = 200
    20.         .Enabled = True
    21.         .Protection = msoBarNoCustomize
    22.         .Visible = True
    23.     End With
    24. End Sub

    Edit: played around with spaces and Left$ enough to figure it out
    Last edited by VBAhack; Mar 11th, 2006 at 08:16 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width