Creating Toolbars

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Through VBA coding how can a new Toolbar automatically be creating & also
automatically have a certain Macro to run linked to it ?

I playing around with the CommandBars Object but couldnt figure it out.

So for example to have a new ToolBar called "RemoveData" & have a XLA Macro
called "RemoveData" linked to it ? Also so that the toolbar shows in the Top
section of the screen where the rest of the toolbars are.

Any help would be greatly appreciated.

Thank you,
Jeff
 
Something along these lines will create a menu for you:-

Set myMenuBar = CommandBars.ActiveMenuBar
Set newMenu = myMenuBar.Controls.Add(Type:=msoControlPopup, _
before:=8, Temporary:=True)
newMenu.Caption = "New Menu"
Set MenuItem = newMenu.Controls _
.Add(Type:=msoControlButton, ID:=1)
With MenuItem
.Caption = "Remove Data"
.FaceId = 110
.TooltipText = "Data Removal"
.OnAction = "removeData"
End With

Then, you can remove it when shutting down by using:-

Application.CommandBars("Worksheet Menu Bar").Controls("New Menu").Delete
 

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