#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel toolbar like word toolbar, please Meng[_2_] Excel Discussion (Misc queries) 1 May 23rd 09 04:28 PM
Form Toolbar verses Control Toolbar ub Excel Discussion (Misc queries) 3 July 11th 08 10:57 PM
Adjusting toolbar size, restore toolbar Josh M Excel Discussion (Misc queries) 1 January 18th 06 06:17 PM
How can I keep Toolbar Buttons on the toolbar? weberts2 Setting up and Configuration of Excel 1 July 16th 05 04:30 AM
saving toolbar buttons on custom toolbar Paul James Excel Programming 12 August 6th 03 08:28 AM


All times are GMT +1. The time now is 11:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"