Consulting

Results 1 to 11 of 11

Thread: Solved: Floating Toolbars

  1. #1
    VBAX Expert
    Joined
    May 2006
    Location
    Oklahoma City, OK
    Posts
    532
    Location

    Solved: Floating Toolbars

    Good morning to everyone...depending on where you are. I'm using "lucas" (thank you) floating toolbar on the KB (http://vbaexpress.com/kb/getarticle.php?kb_id=921). My question is...can you have more than one floating toolbar displayed simultaneously? My reason for asking is that I want different toolbars to perform different functions on the same worksheet. I'm making an interactive baseball scorecard and I want different toolbars for; how runners get on base; how batters make out; and ways runners advance, etc. I would also like to set the color for each toolbar to help the user to differentiate between the toolbars. This is an example of what I have for the toolbar for How Runners Get on Base; Any suggestions are also appreciated.

    [VBA]Sub AddNewToolBar()
    ' This procedure creates a new temporary toolbar.
    Dim ComBar As CommandBar, ComBarContrl As CommandBarControl
    On Error GoTo ErrorHandler
    ' Create a new floating toolbar and make it visible.
    On Error Resume Next
    'Delete the toolbar if it already exists
    CommandBars("Baseball Scorecard Toolbar").Delete
    Set ComBar = CommandBars.Add(Name:="How Runners Get on Base", Position:= _
    msoBarFloating, Temporary:=True)
    ComBar.Visible = True
    ' Create a button with text on the bar and set some properties.
    Set ComBarC With ComBarContrl
    .Caption = "Single"
    . .TooltipText = "Run Single"
    'the onaction line tells the button to run a certain marcro
    .
    End With
    Set ComBarC With ComBarContrl
    .Caption = "Double"
    . .TooltipText = "Run Double"
    'the onaction line tells the button to run a certain marcro
    .
    End With
    Set ComBarC With ComBarContrl
    .Caption = "Triple"
    . .TooltipText = "Run Triple"
    'the onaction line tells the button to run a certain marcro
    .
    End With
    Set ComBarC With ComBarContrl
    .Caption = "HR"
    . .TooltipText = "Run Home Run"
    'the onaction line tells the button to run a certain marcro
    .
    End With
    Set ComBarC With ComBarContrl
    .Caption = "BB"
    . .TooltipText = "Run BB"
    'the onaction line tells the button to run a certain marcro
    .
    End With
    Set ComBarC With ComBarContrl
    .Caption = "HBP"
    . .TooltipText = "Run HBP"
    'the onaction line tells the button to run a certain marcro
    .
    End With
    Set ComBarC With ComBarContrl
    .Caption = "FC"
    . .TooltipText = "Run Fielders Choice"
    'the onaction line tells the button to run a certain marcro
    .
    End With
    Set ComBarC With ComBarContrl
    .Caption = "GRD"
    . .TooltipText = "Run Ground Rule Double"
    'the onaction line tells the button to run a certain marcro
    .
    End With
    Set ComBarC With ComBarContrl
    .Caption = "WP"
    . .TooltipText = "Run Wild Pitch"
    'the onaction line tells the button to run a certain marcro
    .
    End With
    Set ComBarC With ComBarContrl
    .Caption = "PB"
    . .TooltipText = "Run Pass Ball"
    'the onaction line tells the button to run a certain marcro
    .
    End With
    Set ComBarC With ComBarContrl
    .Caption = "DI"
    . .TooltipText = "Run Defenbive Interference"
    'the onaction line tells the button to run a certain marcro
    .
    End With
    Exit Sub
    ErrorHandler:
    MsgBox "Error " & Err.Number & vbCr & Err.Description
    Exit Sub
    End Sub[/VBA]
    Best regards,

    Charlie

    I need all the I can get....

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Your code is not even close to working.

    BUt why not just have one toolbar with different sections?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Expert
    Joined
    May 2006
    Location
    Oklahoma City, OK
    Posts
    532
    Location
    Hello Bob thanks for replying. For whatever reason the "onaction" part of the coding didn't copy, but the the coding does work. How do you go about sectioning in the same toolbar? In the scorecard there will be as many as 70 different buttons that the person keeping score can select from. You might be saying 70 buttons is this guy nuts that's a lot. But if you've ever kept score by hand at a baseball game there's that many choices for a person keeping score and then some. Once you play around with the buttons it's really pretty easy that's why I thought of color coding each toolbar might make it even easier. It's for the diehard score keepers.


    [vba]Sub AddNewToolBar()
    ' This procedure creates a new temporary toolbar.
    Dim ComBar As CommandBar, ComBarContrl As CommandBarControl
    On Error GoTo ErrorHandler
    ' Create a new floating toolbar and make it visible.
    On Error Resume Next
    'Delete the toolbar if it already exists
    CommandBars("Baseball Scorecard Toolbar").Delete
    Set ComBar = CommandBars.Add(Name:="Baseball Scorecard Toolbar", Position:= _
    msoBarFloating, Temporary:=True)
    ComBar.Visible = True
    ' Create a button with text on the bar and set some properties.

    Set ComBarC With ComBarContrl
    .Caption = "Single"

    . .TooltipText = "Run Single"
    .
    End With

    Set ComBarC With ComBarContrl
    .Caption = "Double"

    . .TooltipText = "Run Double"
    .
    End With

    Set ComBarC With ComBarContrl
    .Caption = "Triple"

    . .TooltipText = "Run Triple"
    .
    End With

    Set ComBarC With ComBarContrl
    .Caption = "HR"

    . .TooltipText = "Run Home Run"
    .
    End With

    Set ComBarC With ComBarContrl
    .Caption = "BB"

    . .TooltipText = "Run BB"
    .
    End With

    Set ComBarC With ComBarContrl
    .Caption = "HBP"

    . .TooltipText = "Run HBP"
    .
    End With

    Set ComBarC With ComBarContrl
    .Caption = "FC"

    . .TooltipText = "Run Fielders Choice"
    .
    End With

    Set ComBarC With ComBarContrl
    .Caption = "GRD"

    . .TooltipText = "Run Ground Rule Double"
    .
    End With

    Set ComBarC With ComBarContrl
    .Caption = "WP"

    . .TooltipText = "Run Wild Pitch"
    .
    End With

    Set ComBarC With ComBarContrl
    .Caption = "PB"

    . .TooltipText = "Run Pass Ball"
    .
    End With

    Set ComBarC With ComBarContrl
    .Caption = "DI"

    . .TooltipText = "Run Defenbive Interference"
    .
    End With
    Exit Sub
    ErrorHandler:
    MsgBox "Error " & Err.Number & vbCr & Err.Description
    Exit Sub
    End Sub[/vba]
    Best regards,

    Charlie

    I need all the I can get....

  4. #4
    VBAX Expert
    Joined
    May 2006
    Location
    Oklahoma City, OK
    Posts
    532
    Location
    That's really bizarre the VBA coding that i downloaded didn't showpu correctly. I copied my code over into the Message Box properly, but when it copies over into the thread is not even close to what I put in there????
    Best regards,

    Charlie

    I need all the I can get....

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    70 buttons is a lot, regardless of whether you have them on one toolbar or on many.

    Is there any way that you can determine which toolbar is relevant at any one time?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    VBAX Expert
    Joined
    May 2006
    Location
    Oklahoma City, OK
    Posts
    532
    Location
    There's not any one toolbar more relevant than the other. They are are going to be used equally. One is for the how the batter does or doesn't get on base, another for how the runners on base make outs, one for the runners on base and how they advance, and another for how the fielders make outs or errors. Are you a baseball fan Bob?
    Best regards,

    Charlie

    I need all the I can get....

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    No I'm not a baseball fan, I'm a sports fan

    By relevant, I don't mean how often they would get used, but when they would get used. For instance, is there any way that you could identify that when a user is in this cell, toolbar A should be available, in another cell tollbar VB should be available?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Post a workbook with some toolbars Charlie top work with.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    VBAX Expert
    Joined
    May 2006
    Location
    Oklahoma City, OK
    Posts
    532
    Location
    Here's a small sample of the scorecard. Open the workbook and activate the macro "AddNewToolBar" through Tools-Macro, the toolbar will activate with one button on it "Single", click on cell "D4" on worksheet2, click on the toolbar button "Single". This should give you an idea of what takes place on the scorecard.
    Best regards,

    Charlie

    I need all the I can get....

  10. #10
    VBAX Expert
    Joined
    May 2006
    Location
    Oklahoma City, OK
    Posts
    532
    Location
    Here's the workbook...
    Last edited by coliervile; 03-22-2008 at 07:26 AM.
    Best regards,

    Charlie

    I need all the I can get....

  11. #11
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    That isn't exactly doing anything for me I am afraid. I don't understand what is happening, or why, nor do I really care.

    I was hoping to see two or three of your toolbars. And what about the questions that I answered in #7?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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