Initiating a Custom Toolbar

B

Bishop

I have code that creates a custom toolbar, adds a button to it and assigns a
macro to that button. How do I initialize the toolbar/button when the
spreadsheet is opened. Also, once the toolbar/button has been loaded once it
doesn't need to run everytime the spreadsheet is open so I need a way to
check for the toolbar in excel, if it's there do nothing, if not I need it to
run. I have included my code below.

Sub CatalystDumpToolBar()

Dim CDToolBar As CommandBar

Set CDToolBar = CommandBars.Add(temporary:=True)
With CDToolBar
.Name = "CDToolBar"
.Position = msoBarTop
.Visible = True
End With
End Sub


Sub AddCustomControl()

Dim CBar As CommandBar
Dim CTTally As CommandBarControl

Set CBar = CommandBars("CDToolBar")
Set CTTally = CBar.Controls.Add(Type:=msoControlButton)

With CTTally
.FaceId = 1763
.OnAction = "CatalystToTally"
End With
CBar.Visible = True

End Sub
 

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