Selection.Find.Execute jumping to different doc.

J

jbneb

I have VBA code in a template that creates documents, and part of the code uses Selection.Find.Execute to find/replace text. In Word 2002/XP, the ActiveWindow is being changed to a previous document when the Execute occurs. This doesn't appear to be a problem in Word 2000. My best guess is that it is searching both docs. Does Word 2002/XP VBA have a "feature" that searches multiple documents at the same time? If not, what else could this be?
 
T

Tom Winter

jbneb said:
I have VBA code in a template that creates documents, and part of the code
uses Selection.Find.Execute to find/replace text. In Word 2002/XP, the
ActiveWindow is being changed to a previous document when the Execute
occurs. This doesn't appear to be a problem in Word 2000. My best guess is
that it is searching both docs. Does Word 2002/XP VBA have a "feature" that
searches multiple documents at the same time? If not, what else could this
be?

I haven't experienced this, but many of the experts in these newsgroups talk
about how the Selection object in newer versions of Word has changed its
behavior with regards to multiple documents, etc. Your best solution is not
to use the Selection object. Try going through ActiveDocument.Content.Find
or ActiveDocument.StoryRanges(...).Find. Something like that.

-Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top