D
DonRange
A find and replace done manually from the dialog box in Word 2003 reports the
number of replacements made upon completion of the operation with a message
such as "Word has completed its search of the document and has made 5
replacements." If I record this operation with the Macro Recorder, the VBA
code listed below is recorded. When I execute this code from the VBA editor
the replacements are correctly made, but no notification box with the count
of how many were made is generated. What can I add to the VBA code to have
it return the count?
Sub Macro6()
'
' Macro6 Macro
' Macro recorded 11/8/2008 by Donald Range
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "grace"
.Replacement.Text = "gracie"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
number of replacements made upon completion of the operation with a message
such as "Word has completed its search of the document and has made 5
replacements." If I record this operation with the Macro Recorder, the VBA
code listed below is recorded. When I execute this code from the VBA editor
the replacements are correctly made, but no notification box with the count
of how many were made is generated. What can I add to the VBA code to have
it return the count?
Sub Macro6()
'
' Macro6 Macro
' Macro recorded 11/8/2008 by Donald Range
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "grace"
.Replacement.Text = "gracie"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub