Making a macro repeat

D

David Hogarth

Hi,

I have written a macro (Word 2000, but I guess it will work in other
versions too) that does some manipulation I want. But it just does it once.
Can anyone tell me what code I need to wrap it in to make it run repeatedly
to the end of the document?

It does a find next for the next string to be processed, so there are no
problems about running it again from where it is at the end of its
execution, by the way.

Thanks

David
 
J

Jay Freedman

Hi,

I have written a macro (Word 2000, but I guess it will work in other
versions too) that does some manipulation I want. But it just does it once.
Can anyone tell me what code I need to wrap it in to make it run repeatedly
to the end of the document?

It does a find next for the next string to be processed, so there are no
problems about running it again from where it is at the end of its
execution, by the way.

Thanks

David

The preferred method is not to repeat the whole macro.

If it's possible to do the job with a ReplaceAll, that will be the
fastest and most efficient way. For example, see
http://word.mvps.org/FAQs/MacrosVBA/FindReplaceAllWithVBA.htm.

If the processing you need to do can't be handled by ReplaceAll, then
set up a loop whose condition is the boolean value returned by the
..Execute method (True if the search was successful, False if there are
no more occurrences). For an example of this, see
http://word.mvps.org/FAQs/MacrosVBA/ReplceTextWithDoc.htm.
 

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