ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding Toolbar at startup (https://www.excelbanter.com/excel-programming/284883-adding-toolbar-startup.html)

Brian McGuire[_2_]

Adding Toolbar at startup
 
I would like to add a toolbar whenever Excel is started. Right now I have a click-button to add data on the first sheet of a workbook, and would like for the control toolbox toolbar to be added to the users toolbar everytime this workbook is opened. Can this possibly be done via macro or some other way? Thanks in advance.

Brian

Dave Ramage[_3_]

Adding Toolbar at startup
 
Brian,

Add this to the Workbook module:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("CB_Test").Delete
End Sub

Private Sub Workbook_Open()
Dim cb As CommandBar
Dim cbb As CommandBarButton

On Error Resume Next
Application.CommandBars("CB_Test").Delete

Set cb = Application.CommandBars.Add(Name:="CB_Test", _
Position:=msoBarTop, temporary:=True)
Set cbb = cb.Controls.Add(Type:=msoControlButton)
With cbb
.TooltipText = "Click me!"
.FaceId = 10
.OnAction = ThisWorkbook.Name & "!RunMe"
End With
cb.Visible = True
End Sub

This will run the RunMe macro when the button is pressed.

Cheers,
Dave
-----Original Message-----
I would like to add a toolbar whenever Excel is started.

Right now I have a click-button to add data on the first
sheet of a workbook, and would like for the control
toolbox toolbar to be added to the users toolbar everytime
this workbook is opened. Can this possibly be done via
macro or some other way? Thanks in advance.

Brian
.


Brian McGuire[_2_]

Adding Toolbar at startup
 
That did the trick, thanks.

Brian


All times are GMT +1. The time now is 08:33 PM.

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