Article ID: 183850
Article Last Modified on 6/17/2005
Sub CreatePauseToolbar()
Dim NewBar As CommandBar
' Creates the toolbar, and sets a variable to easily format it
Set NewBar = CommandBars.Add
With NewBar
' Sets the toolbar's name
.Name = "Pause"
' Makes the toolbar visible
.Visible = True
' Adds a button to the toolbar
.Controls.Add Type:=msoControlButton
With .Controls(1)
' Sets the style of the button to text only
.Style = msoButtonCaption
' Sets the caption of the button
.Caption = "Continue"
' Assigns the macro PartTwo to the button
.OnAction = "PartTwo"
End With
End With
End Sub
Sub PartOne()
' Prompt the user to select a range
MsgBox "Select the Border Range, then" & Chr(13) & _
"click the Continue button."
' Run the procedure that creates the toolbar
CreatePauseToolbar
End Sub
Sub PartTwo()
' Applies the border to the selected range
Selection.BorderAround Weight:=xlThick
' Deletes the Pause toolbar
CommandBars("Pause").Delete
End Sub
141693 XL: Scope of Variables in Visual Basic for Applications
176476 OFF: Office Assistant Not Answering Visual Basic Questions
Additional query words: XL98 command bar
Keywords: kbhowto kbprogramming kbdtacode KB183850