Custom Toolbar

G

Guest

I have added a custome toolbar with the following code. I would like to add
a tooltip to this button. Also, can I have a button with text instead of the
icon?

Dim cb As CommandBar
Set cb = CommandBars.Add
With cb
.Name = "SWAP"
.Position = msoBarTop
End With

Set myBar = CommandBars("SWAP")
Set myControl = myBar.Controls _
.Add(Type:=msoControlButton, _
Temporary:=True)
With myControl
.FaceId = 47
.Width = 75
.OnAction = "ResetValues"
End With
myBar.Visible = True

Many Thanks
 
J

JE McGimpsey

One way:

With Application.CommandBars
On Error Resume Next
.Item("SWAP").Delete
On Error GoTo 0
With .Add( _
Name:="SWAP", _
Position:=msoBarTop, _
MenuBar:=False, _
Temporary:=True)
With .Controls.Add( _
Type:=msoControlButton, _
Id:=1, _
Before:=1, _
Temporary:=True)
'.FaceId = 47
.Width = 75
.Style = msoButtonCaption
.Caption = "Caption"
.TooltipText = "Tooltip Text"
.OnAction = "ResetValues"
End With
.Visible = True
End With
End With
 
G

Guest

Thanks. That worked great. Is there a way to hide macros so that a user
cannot run them? I am not very good with Excel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top