Add ins

  • Thread starter Thread starter HSalim[MVP]
  • Start date Start date
H

HSalim[MVP]

Hi
I am back after a short break. My add-in is ready for roll-out except for a
few finishing touches where I need help.
The Add-in will be used once a month, so I don't need the add-in to be
loaded every time excel starts.
I have a tool bar that the user can make visible and then click on the
buttons to launch the process.
This tool bar is created in the add-in.

So the question is: how do i distibute the add-in and then make the toolbar
available to the user - once they have the tool bar, it can be hidden or
enabled... but how do i get it to be there first?

How do i suppress the macro warning?

Thanks in advance for your assistance.

Regards
Habib
 
Here is how to add a toolbar

Option Explicit


Const sToolbar As String = "myToolbar"


Private Sub Workbook_BeforeClose(Cancel As Boolean)


On Error Resume Next
Application.CommandBars(sToolbar).Delete
On Error GoTo 0


End Sub


Private Sub Workbook_Open()
Dim cMenu1 As CommandBarControl
Dim cbToolbar As CommandBar


On Error Resume Next
Application.CommandBars(sToolbar).Delete
On Error GoTo 0


Set cbToolbar = Application.CommandBars.Add(sToolbar, , False, True)


With cbToolbar
With .Controls.Add(Type:=msoControlButton)
.BeginGroup = True
.Caption = "Button 1"
.FaceId = 1
.OnAction = "macro1"
End With
With .Controls.Add(Type:=msoControlButton)
.BeginGroup = True
.Caption = "Button 2"
.FaceId = 2
.OnAction = "macro2"
End With
With .Controls.Add(Type:=msoControlButton)
.BeginGroup = True
.Caption = "Button 2"
.FaceId = 3
.OnAction = "macro3"
End With
With .Controls.Add(Type:=msoControlButton)
.BeginGroup = True
.Caption = "Button 4"
.FaceId = 4
.OnAction = "macro4"
End With
With .Controls.Add(Type:=msoControlButton)
.BeginGroup = True
.Caption = "Button 5"
.FaceId = 5
.OnAction = "macro5"
End With
.Visible = True
.Position = msoBarTop
End With


End Sub


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)
 
Bob,
Thanks for the reply.
I have the code in my add-in to create the toolbar.

I want Excel to recreate the toolbar from the add-in when excel is starts.
How do I do tht?
Regards
Habib
 

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

Back
Top