troubleshooting Question

Find next string in word document

Avatar of cosma20
cosma20 asked on
Microsoft WordVisual Basic.NET
5 Comments1 Solution960 ViewsLast Modified:
Hallo,

I need to find a string in an word document with multiple occurences. When found, it must be selected and some things are done with the selection (no replacement)

This Code works fine:

                Dim myrange As Word.Range
                myrange = myDoc.Content
                myrange.Find.ClearFormatting()
                myrange.Find.Text = l_strShortFile 'the string to be found

                If myrange.Find.Execute Then

                    myrange.Select()
                   ' here I use the selection (the found string), to insert bookmarks and so on ...

               End If


with the FIRST occurrence of the string. All other occurrences are ignored.

I made many tries with 'WdFindWrap.wdFindContinue' and Dos and Loops and While ...

but couldn't get it to work.

Can you please help me?

Ingrid
ASKER CERTIFIED SOLUTION
GrahamSkan
Retired
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros