View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Macro & Tool Bar Sharing

Juan,

the best way is to put it in the workbook open event, building it when it is
opened. Here is an example, it goes in the ThisWorkbook code module

Sub Workbook_Open()
Dim oCB As CommandBar
Dim oCBCtrl As CommandBarControl

'Delete CommandBar if it exists
On Error Resume Next
Application.CommandBars("myToolbar").Delete
On Error GoTo 0

Set oCB = Application.CommandBars.Add(Name:="myToolbar",
temporary:=True)

With oCB
Set oCBCtrl = .Controls.Add(temporary:=True)
With oCBCtrl
.Caption = "Function 1"
.FaceId = 197
.OnAction = "myFunc1"
End With
Set oCBCtrl = oCB.Controls.Add(temporary:=True)
With oCBCtrl
.Caption = "Function 2"
.FaceId = 198
.OnAction = "myFunc2"
End With
Set oCBCtrl = oCB.Controls.Add(temporary:=True)
With oCBCtrl
.Caption = "Function 3"
.FaceId = 199
.OnAction = "myFunc3"
End With
.Visible = True
.Position = msoBarTop
End With

End Sub


Also, check out John Walkenbach's FaceId utility to see what icons are
available to use at
http://j-walk.com/ss/excel/tips/tip67.htm


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Juan" wrote in message
...
Hi all...

looking at the reply to the post macro sharing from Rob by
Bob, I have another question regarding this...

How do I add a Tool Bar to a AddIn File so that when the
addin is loaded so is the toolbar.

regards
Juan