PC Review


Reply
Thread Tools Rate Thread

Create toolbar

 
 
Fredrik E. Nilsen
Guest
Posts: n/a
 
      26th Jan 2007
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 With Quote
 
 
 
 
Jon Peltier
Guest
Posts: n/a
 
      27th Jan 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
"cannot create toolbar"...trying to bring back Quick Launch toolbar jbclem Microsoft Windows 2000 9 8th Jan 2009 01:57 AM
toolbar browser - google toolbar sux (create your own toolbar) (ProteanThread) Freeware 1 12th May 2005 02:55 AM
Create toolbar-help jminu Microsoft Excel Programming 1 14th Sep 2004 07:22 AM
create Add-ins toolbar shital Microsoft Excel Misc 4 10th May 2004 01:10 PM
(Quick Launch) Toolbar: Cannot create toolbar for " David Hyer Microsoft Windows 2000 1 30th Sep 2003 05:54 AM


Features
 

Advertising
 

Newsgroups
 


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