L
LEU
I have the following macro that finds a word in my document then bolds and
Caps it. My problem is if I call the macro and try to close it using the red
close box in the upper right corner of the InputBox the macro blows up. How
do I tell it to close if the close box is clicked?
Sub FindWord()
Dim SearchRange As Range
Set SearchRange = ActiveDocument.Range
With SearchRange.Find
..Text = InputBox("Word to Bold and Cap:")
..MatchWholeWord = True
While .Execute
Select Case SearchRange.Style
Case "Hd1", "Hd2", "Hd3", "Hd4"
SearchRange.Font.AllCaps = True
SearchRange.Font.Bold = True
End Select
Wend
End With
End Sub
Caps it. My problem is if I call the macro and try to close it using the red
close box in the upper right corner of the InputBox the macro blows up. How
do I tell it to close if the close box is clicked?
Sub FindWord()
Dim SearchRange As Range
Set SearchRange = ActiveDocument.Range
With SearchRange.Find
..Text = InputBox("Word to Bold and Cap:")
..MatchWholeWord = True
While .Execute
Select Case SearchRange.Style
Case "Hd1", "Hd2", "Hd3", "Hd4"
SearchRange.Font.AllCaps = True
SearchRange.Font.Bold = True
End Select
Wend
End With
End Sub