Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Floating toolbar and floating comment? StargateFan[_3_] Excel Programming 2 December 5th 05 10:26 PM
Floating Toolbar Dave Excel Discussion (Misc queries) 4 April 29th 05 04:57 PM
PDF 4.0 Floating Toolbar Darrell Excel Discussion (Misc queries) 1 February 10th 05 06:14 PM
floating toolbar scottwilsonx[_67_] Excel Programming 2 October 29th 04 01:24 PM
Floating Toolbar Roger Bedford[_2_] Excel Programming 2 July 6th 04 06:03 PM


All times are GMT +1. The time now is 06:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"