Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
ToolBar
I am trying have VBA Create a toolbar named SGSFormat on a Open event if it
does not see that it is already created. I need it to populate 3 new buttons with macros in the Personal.xls file. Any ideas? Thanks in advance Aaron |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
ToolBar
Here is an article about creating commandbars with code:
http://msdn.microsoft.com/library/techart/ofcmdbar.htm -- Regards, Tom Ogilvy "Aaron" wrote in message ... I am trying have VBA Create a toolbar named SGSFormat on a Open event if it does not see that it is already created. I need it to populate 3 new buttons with macros in the Personal.xls file. Any ideas? Thanks in advance Aaron |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
ToolBar
Aaron,
Here is an example Option Explicit 'If you put code in the appropriate workbook open event, and 'delete it in the close it will exist only for that workbook. 'Here is an example of a building a commandbar on the fly 'when you open a workbook. It adds a sub-menu to the Tools menu. Private Sub Workbook_Open() Dim oCb As CommandBar Dim oCtl As CommandBarPopup Dim oCtlBtn As CommandBarButton Set oCb = Application.CommandBars("Worksheet Menu Bar") With oCb Set oCtl = .Controls("SGSFormat").Add( _ Type:=msoControlPopup, _ temporary:=True) oCtl.Caption = "myButton" With oCtl Set oCtlBtn = .Controls.Add( _ Type:=msoControlButton, _ temporary:=True) oCtlBtn.Caption = "myMacroButton" oCtlBtn.FaceId = 161 oCtlBtn.OnAction = "myMacro" End With With oCtl Set oCtlBtn = .Controls.Add( _ Type:=msoControlButton, _ temporary:=True) oCtlBtn.Caption = "myMacroButton2" oCtlBtn.FaceId = 161 oCtlBtn.OnAction = "myMacro2" End With 'etc. End With End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim oCb As CommandBar Set oCb = Application.CommandBars("Worksheet Menu Bar") oCb.Controls("SGSFormat").Delete End Sub 'To add this, go to the VB IDE (ALT-F11 from Excel), and in 'the explorer pane, select your workbook. Then select the 'ThisWorkbook object (it's in Microsoft Excel Objects which 'might need expanding). Double-click the ThisWorkbook and 'a code window will open up. Copy this code into there, 'changing the caption and action to suit. 'This is part of the workbook, and will only exist with the 'workbook, but will be available to anyone who opens the 'workbook. -- HTH RP (remove nothere from the email address if mailing direct) "Aaron" wrote in message ... I am trying have VBA Create a toolbar named SGSFormat on a Open event if it does not see that it is already created. I need it to populate 3 new buttons with macros in the Personal.xls file. Any ideas? Thanks in advance Aaron |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
ToolBar
I have commandbar examples on my website.
-- Rob van Gelder - http://www.vangelder.co.nz/excel "Aaron" wrote in message ... I am trying have VBA Create a toolbar named SGSFormat on a Open event if it does not see that it is already created. I need it to populate 3 new buttons with macros in the Personal.xls file. Any ideas? Thanks in advance Aaron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
excel toolbar like word toolbar, please | Excel Discussion (Misc queries) | |||
Form Toolbar verses Control Toolbar | Excel Discussion (Misc queries) | |||
Adjusting toolbar size, restore toolbar | Excel Discussion (Misc queries) | |||
How can I keep Toolbar Buttons on the toolbar? | Setting up and Configuration of Excel | |||
saving toolbar buttons on custom toolbar | Excel Programming |