Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2005

Tip: Looking for answers? Try searching our database.

Making a macro repeat

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Hogarth - 29 Jun 2005 22:14 GMT
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
Jay Freedman - 30 Jun 2005 02:03 GMT
>Hi,
>
[quoted text clipped - 10 lines]
>
>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.

--
Regards,
Jay Freedman
Microsoft Word MVP         FAQ: http://word.mvps.org
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.