PDA

View Full Version : Solved: mySelection.Find.Execute



fcoreyesv
04-15-2005, 12:20 PM
I am working with a program to change text with the function

mySelection.Find.Execute

but I would like to get the result of the function in numbers. Like the word interface does, giving the number of instances replaced trhoughout the document.

Do I need to use a differente function or I am missing something? :dunno

Thanks in advance for your help and comments:hi:

Joey


Never mind guys. I was thinking inside the box. I need to run a cycle before with a counter only to FIND the occurrences and then run the replace option.

Thanks anyway :)

MOS MASTER
04-16-2005, 11:16 AM
Hi, :D

Welcome to VBAX!

Glad to see you've made it work. Can you post you're code for others to benifit from it? :thumb

fcoreyesv
04-21-2005, 09:21 AM
This is the code:


mySelection = Worddoc.Range

bFound = True

Do While bFound = True

bFound = mySelection.Find.Execute(txtFind.Text)

If bFound = True Then

iCounter = iCounter + 1

End If

Loop

mySelection = Worddoc.Range

bFound = True

bFound = mySelection.Find.Execute(txtFind.Text, , True, , , , False, , , txtReplace.Text, Word.WdReplace.wdReplaceAll, , , , )

bFound = True

Do While bFound = True

bFound = mySelection.Find.Execute(txtReplace.Text)

If bFound = True Then

mySelection.HighlightColorIndex = Word.WdColorIndex.wdYellow

End If

Loop

MsgBox("The text was found " & iCounter & " times")

MOS MASTER
04-24-2005, 06:41 AM
Hi, :D

Thnxx for posting back! :thumb