Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Phil Sanchez   on Sep 12 In MS Office Category.

  
Question Answered By: Adalhelm Fischer   on Sep 12

In the VBA IDE, go into the project explorer, under the add-in  project, Excel
Objects, "This Workbook", Workbook_Open event, place your code to create and
populate the toolbar. Then in Excel, Tools -> Add-Ins, make sure you have your
add-in selected. Whenever you load Excel, the toolbar  should be visible.

Example toolbar code that would create a toolbar with a single "start" button
would look something like this:

Dim StartButton as CommandBarButton
Application.Commandbars.Add(Name:="MyAddin", temporary:=True).Visible = True

Set StartButton = Application.CommandBars("MyAddin").Controls.Add _
(Type:=msoControlButton, ID:=2950, temporary:=True)
With StartButton
.Style = msoButtonCaption
.Caption = "Start"
.OnAction = "MyStartRoutine"
.ToolTipText = "Start my custom addin"
End With

Application.CommandBars("MyAddin").Position = msoBarTop

In a module in your addin, you would need a sub called "MyStartRoutine" that
will execute when you click on the "Start" button on your toolbar.

Share: 

 
 
Didn't find what you were looking for? Find more on Distributing toolbar Or get search suggestion and latest updates.


Tagged: