View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Floating Command button

This is very basic but it should give you a start... this code needs to be in
a standard code module.

Private Const MyBarName As String = "My Command Bar"

Public Sub AddMyBar()
Dim cbrMyBar As CommandBar
Dim btn As CommandBarButton

Set cbrMyBar = Application.CommandBars.Add(MyBarName)
cbrMyBar.Visible = True
Set btn = cbrMyBar.Controls.Add(Type:=msoControlButton)
With btn
.Style = msoButtonCaption
.Caption = "Tada"
.OnAction = "DoStuff"
End With
End Sub

Public Sub DeleteMyBar()
On Error Resume Next
Application.CommandBars(MyBarName).Delete
End Sub

Public Sub DoStuff()
MsgBox "Stuff"
End Sub

--
HTH...

Jim Thomlinson


"kev_06" wrote:


It's come to my attention that I have no idea how to add command buttons
to a commandbar.


--
kev_06
------------------------------------------------------------------------
kev_06's Profile: http://www.excelforum.com/member.php...o&userid=35046
View this thread: http://www.excelforum.com/showthread...hreadid=551659