By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,057 Members | 1,346 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,057 IT Pros & Developers. It's quick & easy.

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

P: 1
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
Share this question for a faster answer!
Share on Google+

Post your reply

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