Article ID: 161535
Article Last Modified on 11/23/2006
Sub CreatePauseToolbar()
Dim NewBar As Object
'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
131847 Creating a PAUSE Button in visual Basic for Applications
Additional query words: 97 8.00 XL97 command bar
Keywords: kbdtacode kbhowto kbprogramming kbui KB161535