Microsoft Office Tutorials and References
In Depth Information
Creating a Custom Toolbar
'Show the icon and the text¶
.Style = msoButtonIconAndCaption¶
.OnAction = "SampleMacro1"¶
.TooltipText = "This is the tool tip"¶
End With¶
'Add a submenu¶
Set Submenu = .Controls.Add(Type:=msoControlPopup)¶
'Change some properties¶
With Submenu¶
'Popups can't have an image associated¶
.Caption = "My submenu"¶
'Put a division before the control¶
.BeginGroup = True¶
'Now add a dummy button in there¶
Set Button = .Controls.Add(Type:=msoControlButton)¶
Button.Caption = "Dummy button"¶
'Only display the text¶
Button.Style = msoButtonCaption¶
'Disable it¶
Button.Enabled = False¶
End With¶
'Add the textbox¶
Set TextBox = .Controls.Add(Type:=msoControlEdit)¶
TextBox.BeginGroup = True¶
TextBox.Text = "Sample text"¶
TextBox.Tag = BarTextBox¶
'Add a button to control the TextBox¶
Set Button = .Controls.Add(Type:=msoControlButton)¶
Button.Caption = "Show"¶
Button.Style = msoButtonCaption¶
Button.OnAction = "SampleMacro2"¶
'Add the ComboBox¶
Set ComboBox = .Controls.Add(Type:=msoControlDropdown)¶
'Add items¶
ComboBox.AddItem "Item 1"¶
ComboBox.AddItem "Item 2"¶
ComboBox.AddItem "Item 3"¶
ComboBox.BeginGroup = True¶
ComboBox.OnAction = "SampleMacro3"¶
ComboBox.Tag = BarComboBox¶
'Finally, make it visible¶
.Visible = True¶
End With¶
End Sub¶
' * * * * *¶
Sub DeleteToolbar()¶
'Try to delete the bar, if it doesn't exist, ignore the error¶
On Error Resume Next¶
End Sub¶
Search JabSto ::

Custom Search