Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Create toolbar

Hi,

I use the following code to create a toolbar:

Sub CreateMenubar()

Dim iCtr As Long

Dim MacNames As Variant
Dim CapNamess As Variant
Dim TipText As Variant

Call RemoveMenubar

MacNames = Array("Line", _
"Column", _
"Pie", _
"LineColumn1", _
"LineColumn2", _
"Scatter", _
"StackedColumn")

CapNamess = Array("Line", _
"Column", _
"Pie", _
"LineColumn1", _
"LineColumn2", _
"Scatter", _
"StackedColumn")
TipText = Array("Line chart", _
"Column chart", _
"Pie chart", _
"Line/column 1 axis", _
"Line/column 2 axis", _
"Scatter chart", _
"Stacked column chart")
With Application.CommandBars.Add
.Name = ToolBarName
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating

For iCtr = LBound(MacNames) To UBound(MacNames)
With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & MacNames(iCtr)
.Caption = CapNamess(iCtr)
.Style = msoButtonIconAndCaption
.FaceId = 71 + iCtr
.TooltipText = TipText(iCtr)
End With
Next iCtr
End With
End Sub


This code creates a toolbar with 7 buttons that control other macros.
I see now that I will need more buttons, up to 25 or 30 and I would
like to group them under menus on the toolbar, such as "Lines",
"Columns" etc. Is there an easy way to adjust the current code to
accomodate this?

--
Fredrik E. Nilsen
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Create toolbar

The first example on this page shows how to group commandbar items into
submenus on the commandbar.

http://peltiertech.com/Excel/menus.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Fredrik E. Nilsen" wrote in message
...
Hi,

I use the following code to create a toolbar:

Sub CreateMenubar()

Dim iCtr As Long

Dim MacNames As Variant
Dim CapNamess As Variant
Dim TipText As Variant

Call RemoveMenubar

MacNames = Array("Line", _
"Column", _
"Pie", _
"LineColumn1", _
"LineColumn2", _
"Scatter", _
"StackedColumn")

CapNamess = Array("Line", _
"Column", _
"Pie", _
"LineColumn1", _
"LineColumn2", _
"Scatter", _
"StackedColumn")
TipText = Array("Line chart", _
"Column chart", _
"Pie chart", _
"Line/column 1 axis", _
"Line/column 2 axis", _
"Scatter chart", _
"Stacked column chart")
With Application.CommandBars.Add
.Name = ToolBarName
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating

For iCtr = LBound(MacNames) To UBound(MacNames)
With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" &
MacNames(iCtr)
.Caption = CapNamess(iCtr)
.Style = msoButtonIconAndCaption
.FaceId = 71 + iCtr
.TooltipText = TipText(iCtr)
End With
Next iCtr
End With
End Sub


This code creates a toolbar with 7 buttons that control other macros.
I see now that I will need more buttons, up to 25 or 30 and I would
like to group them under menus on the toolbar, such as "Lines",
"Columns" etc. Is there an easy way to adjust the current code to
accomodate this?

--
Fredrik E. Nilsen



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
Create a toolbar button excelnut1954 Excel Programming 5 March 3rd 06 08:56 PM
Create Toolbar with VBA AMK4[_32_] Excel Programming 4 February 3rd 06 07:37 AM
Create a Temp Toolbar Tempy Excel Programming 4 August 29th 05 04:33 PM
how to create toolbar? tango Excel Programming 0 October 26th 04 12:38 AM
Create toolbar-help jminu Excel Programming 1 September 14th 04 07:22 AM


All times are GMT +1. The time now is 04:20 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"