Microsoft Office Tutorials and References
In Depth Information
Creating a Custom Toolbar
' * * * * *¶
Sub SampleMacro1()¶
MsgBox "Clicked me !"¶
End Sub¶
' * * * * *¶
Sub SampleMacro2()¶
On Error GoTo err_h¶
With Application.CommandBars.FindControl(Tag:=BarTextBox)¶
'Do something with this control¶
MsgBox .Text¶
End With¶
Exit Sub¶
err_h:¶
End Sub¶
' * * * * *¶
Sub SampleMacro3()¶
On Error GoTo err_h¶
With Application.CommandBars.FindControl(Tag:=BarComboBox)¶
'Do something with this control¶
MsgBox .ListIndex¶
End With¶
Exit Sub¶
err_h:¶
End Sub¶
' * * * * *¶
Sub Auto_Open()¶
'Create the toolbar when the workbook is opened¶
CreateToolbar¶
End Sub¶
' * * * * *¶
Sub Auto_Close()¶
'Delete the toolbar when the workbook is closed¶
DeleteToolbar¶
End Sub¶
Exl
The 'CreateToolbar' procedure contains a sample of how to create a toolbar with
buttons, submenus, text boxes, and drop-downs. Adapt this procedure to
display and run whatever macros are appropriate to the menu being created.
The other procedures, 'DeleteToolbar', 'Auto_Open', and 'Auto_Close', can be
left as they are.
Search JabSto ::




Custom Search