ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating Toolbars (https://www.excelbanter.com/excel-programming/331794-creating-toolbars.html)

Jeff

Creating Toolbars
 
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



bigwheel

Creating Toolbars
 
Something along these lines will create a menu for you:-

Set myMenuBar = CommandBars.ActiveMenuBar
Set newMenu = myMenuBar.Controls.Add(Type:=msoControlPopup, _
befo=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



All times are GMT +1. The time now is 10:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com