R
RuGio
Hi, I would like to know a routine to select a text (from a word
(Summer) to another word (Winter)) and to count a specific word
(for example "Sun" ) within in (within the selected text).
I wrote this but it doesn't work! HELP!
Thanks
Sub CountSun()
Counter = 0
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Summer "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.StartOf Unit:=wdWord 'Selection.EndOf Unit:=wdWord
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Winter:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
End With
Selection.Find.Execute
With Selection.Find
Do While .Execute(FindText:="Sun", Format:=False,
MatchCase:=False, MatchWholeWord:=True) = True
Counter = Counter + 1
Loop
End With
End Sub
(Summer) to another word (Winter)) and to count a specific word
(for example "Sun" ) within in (within the selected text).
I wrote this but it doesn't work! HELP!
Thanks
Sub CountSun()
Counter = 0
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Summer "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.StartOf Unit:=wdWord 'Selection.EndOf Unit:=wdWord
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Winter:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
End With
Selection.Find.Execute
With Selection.Find
Do While .Execute(FindText:="Sun", Format:=False,
MatchCase:=False, MatchWholeWord:=True) = True
Counter = Counter + 1
Loop
End With
End Sub