468,301 Members | 1,526 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,301 developers. It's quick & easy.

Help Regarding Counting of how replcement has been made in word document

Hi all this my code to replacce A with B
now i want to find how many replacement it has made in the file

Function FindAReplaceB()
Dim Count As Integer
Count = 0


Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Text = "A"
Selection.Find.Replacement.Text = "B"

'Selection.Find.Forward = True
'Selection.Find.Wrap = wdFindContinue
'Selection.Find.Found = True

With Selection.Find
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceOne
If Not EOF() Then
'Selection.Find.Execute Replace:=wdReplaceOne
Count = Count + 1
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Selection.Find.Execute Replace:=wdReplaceOne
Else
.Collapse Direction:=wdCollapseEnd
End If
MsgBox Count
End If

'Selection.Find.Execute Replace:=wdReplaceAll

End Function

i have done using EOF but i am not able to get it

pls help me guys
Nov 2 '06 #1
0 955

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by rainbowii7 | last post: by
22 posts views Thread by Rich | last post: by
6 posts views Thread by naknak | last post: by
6 posts views Thread by cj2 | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.