Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Example file to dl for floating toolbar?
SF,
Try the code below. Copy it, paste it into a codemodule, and run the macro: AddFloatingCommandbarWith3Buttons HTH, Bernie MS Excel MVP Option Explicit Dim myBar As CommandBar Dim myButton As CommandBarButton Const myName As String = "MyFloatingCBar" Sub AddFloatingCommandbarWith3Buttons() On Error Resume Next Application.CommandBars(myName).Delete Set myBar = Application.CommandBars.Add(myName) With myBar .Position = msoBarFloating .Left = 100 .Top = 200 .Visible = True .Enabled = True Set myButton = .Controls.Add(Type:=msoControlButton, ID:=23) With myButton .Caption = "Hello" .Style = msoButtonIcon .FaceId = 137 .Enabled = True .OnAction = "SayHello" End With Set myButton = .Controls.Add(Type:=msoControlButton, ID:=23) With myButton .Caption = "Goodbye" .Style = msoButtonIcon .FaceId = 138 .Enabled = True .OnAction = "SayGoodbye" End With Set myButton = .Controls.Add(Type:=msoControlButton, ID:=23) With myButton .Caption = "Kill Me" .Style = msoButtonIcon .FaceId = 132 .Enabled = True .OnAction = "KillMe" End With End With End Sub Sub SayHello() MsgBox "Hello" End Sub Sub SayGoodbye() MsgBox "Goodbye" End Sub Sub KillMe() On Error Resume Next Application.CommandBars(myName).Delete End Sub "StargateFan" wrote in message ... Can anyone point me to an example file that actually creates a floating toolbar with, hopefully, at least 2 working buttons on it? I've googled the archives of this ng and all the examples I've tried bring up an extra box along the top menu, mimicking the upper left-hand corner of any sheet along the top (the one that just restores, minimizes and closes). Where I first saw this floating toolbar concept is in an invoice sheet that is completely locked down so I can't see the working code and how it does what it does. Pls, any help would be appreciated. I googled for this and only one example came up (in German <g), which I dl scanned for viruses and tried out but it wasn't the right thing, either. Thanks so much! :oD |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Example file to dl for floating toolbar?
Oh, thank you!! That's great. Now I can see what is going on. I also had
had two questions which seeing the code answered, one concerned the buttons. I see that one can change the button image very easily and it's with the good old FaceID references (for which I have a nifty template that lists them all along with the pix!). Also, a second concern was the position of the toolbar. Very easy to do as I can see from this code. My first view of a floating toolbar was one I used last week. It's the one with the locked code so I couldn't go in to see if the position can be changed. Good to know it's easy as in this particular case, an annoyance is the toolbar sits by default on top of one of the fields to edit so we have to keep dragging it out of the way. Yet very easy to set this via the "left" and "top" numbers for the position in the code below. I now have something to work with. Will go back and google the archives of this ng to try different things out. Thanks a million! :oD "Bernie Deitrick" <deitbe @ consumer dot org wrote in message ... SF, Try the code below. Copy it, paste it into a codemodule, and run the macro: AddFloatingCommandbarWith3Buttons HTH, Bernie MS Excel MVP Option Explicit Dim myBar As CommandBar Dim myButton As CommandBarButton Const myName As String = "MyFloatingCBar" Sub AddFloatingCommandbarWith3Buttons() On Error Resume Next Application.CommandBars(myName).Delete Set myBar = Application.CommandBars.Add(myName) With myBar .Position = msoBarFloating .Left = 100 .Top = 200 .Visible = True .Enabled = True Set myButton = .Controls.Add(Type:=msoControlButton, ID:=23) With myButton .Caption = "Hello" .Style = msoButtonIcon .FaceId = 137 .Enabled = True .OnAction = "SayHello" End With Set myButton = .Controls.Add(Type:=msoControlButton, ID:=23) With myButton .Caption = "Goodbye" .Style = msoButtonIcon .FaceId = 138 .Enabled = True .OnAction = "SayGoodbye" End With Set myButton = .Controls.Add(Type:=msoControlButton, ID:=23) With myButton .Caption = "Kill Me" .Style = msoButtonIcon .FaceId = 132 .Enabled = True .OnAction = "KillMe" End With End With End Sub Sub SayHello() MsgBox "Hello" End Sub Sub SayGoodbye() MsgBox "Goodbye" End Sub Sub KillMe() On Error Resume Next Application.CommandBars(myName).Delete End Sub "StargateFan" wrote in message ... Can anyone point me to an example file that actually creates a floating toolbar with, hopefully, at least 2 working buttons on it? I've googled the archives of this ng and all the examples I've tried bring up an extra box along the top menu, mimicking the upper left-hand corner of any sheet along the top (the one that just restores, minimizes and closes). Where I first saw this floating toolbar concept is in an invoice sheet that is completely locked down so I can't see the working code and how it does what it does. Pls, any help would be appreciated. I googled for this and only one example came up (in German <g), which I dl scanned for viruses and tried out but it wasn't the right thing, either. Thanks so much! :oD |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Floating toolbar and floating comment? | Excel Programming | |||
Floating Toolbar | Excel Discussion (Misc queries) | |||
PDF 4.0 Floating Toolbar | Excel Discussion (Misc queries) | |||
floating toolbar | Excel Programming | |||
Floating Toolbar | Excel Programming |