MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Custom Toolbar - ZOOM


Posted by Robb on February 06, 2002 2:17 PM

At the start of my program I hide all Excel ToolBars, then I dynamically create my custom TOOLBAR using the code below. I need the Zoom Custom Combobox so the user can customize the view of the screen. This is what I have so far and it works fine except for the zoom cbo. All I get is the "Zoom" word without the combobox.

' Location for menu data
Set MenuSheet = ThisWorkbook.Sheets("Colour & Size Lists")

' Create the CommandBar called "Custom"
Set cbar1 = CommandBars.Add(Name:="Custom", Position:=msoBarTop)

' Initialize the row counter
Row = 400

' Add the control data stored on the MenuSheet
Do Until IsEmpty(MenuSheet.Cells(Row, 1))
With MenuSheet
Caption = .Cells(Row, 1)
FaceId = .Cells(Row, 2)
OnAction = .Cells(Row, 3)
Style = .Cells(Row, 4)
TooltipText = .Cells(Row, 5)
BeginGroup = .Cells(Row, 6)
Enabled = .Cells(Row, 7)
End With

' Create the controls for "Custom" CommandBar
Set MenuObject = Application.CommandBars("Custom").Controls _
.Add(Type:=msoControlButton, Before:=1, _
temporary:=True)
MenuObject.Caption = Caption
MenuObject.FaceId = FaceId
MenuObject.OnAction = OnAction
MenuObject.Style = Style
MenuObject.TooltipText = TooltipText
MenuObject.BeginGroup = BeginGroup
MenuObject.Enabled = Enabled

' Move down a row to get the parameters for the next control
Row = Row + 1
Loop

' Show the "Custom" CommandBar
cbar1.Visible = True


Posted by Juan Pablo G. on February 06, 2002 3:40 PM

The ID of the Zoom CommandBarControl is 1733, with that you can do something like this, which copies it and puts it as the first control in the Drawing toolbar.

Application.CommandBars.FindControl(Id:=1733).Copy Application.CommandBars("Drawing"),1

Juan Pablo G.

Posted by Russell Hauf on February 06, 2002 3:49 PM

See my post on your earlier thread (nt)

Posted by Robb on February 06, 2002 4:11 PM

Thanx Juan, works like a charm!!!!