Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2007

Tip: Looking for answers? Try searching our database.

Create toolbar

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fredrik E. Nilsen - 26 Jan 2007 17:53 GMT
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?

Signature

Fredrik E. Nilsen

Jon Peltier - 27 Jan 2007 15:08 GMT
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
_______

> Hi,
>
[quoted text clipped - 58 lines]
> "Columns" etc. Is there an easy way to adjust the current code to
> accomodate this?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.