Results 1 to 3 of 3

Thread: Toolbars in VBA

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    just as global as it gets
    Posts
    71

    Unhappy Toolbars in VBA

    Help!

    I'm busy writing a toolbar for MS Excel and stuck with an Excel 5.0 Manual. Please look at this code, just setting up a new CommandBar and putting a large button in it.

    Code:
    Sub setUpTestBar()
        CommandBars.Add "Test"
        With CommandBars("Test")
            .Visible = True
            .Controls.Add Type:=msoControlButton
            .Controls(1).Caption = "Caption"
            .Controls(1).Enabled = True
            .Controls(1).DescriptionText = "DescText"
            .Controls(1).State = msoButtonUp
            .Controls(1).Visible = True
            .Controls(1).TooltipText = "Tooltip Text"
            .Controls(1).OnAction = "myModule.mySub"
            .Controls(1).Width = 100
        End With
    End Sub
    I can now click the button and it will fire up my program. In fact, it works perfectly, with the exception that I can't make the button bear a name. I don't even want a picture, just a name!
    The PC can't replace your life...
    ...but you can get a great break with it

    VB6, (D)HTML, JavaScript, TI-85
    German, English, Portuguese, Spanish, French & a bit of latin

  2. #2
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    I'm not familiar with the way to do this, but do a search on MSDN for "excel toolbar button caption" and see what turns up.
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    just as global as it gets
    Posts
    71
    Nope, it's this: In each office program, the buttons in the toolbars have this styles:

    -Icon only
    -Text only
    -both

    The default setting for commandBar.commandButton(#).style is msoAutomatic, which takes the property from Excel. And most excel values are Icon only...

    So, setting the .style-property to msoIconCaption (or something) makes it happen

    don't forget to assign a caption after that..

    over and out
    The PC can't replace your life...
    ...but you can get a great break with it

    VB6, (D)HTML, JavaScript, TI-85
    German, English, Portuguese, Spanish, French & a bit of latin

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