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.

combining two loops into one

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Smith - 27 Jun 2005 01:10 GMT
Can the following two loops be combined into one? I need to do
multiple find and replace and it's taking a long time. I hope if I
can do multiple find and replace in just one loop, it'll take less
time.

Do While .Execute(FindText:=" <", ReplaceWIth:="<",
MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True
       Loop

Do While .Execute(FindText:="(", ReplaceWIth:=vbTab + "(",
MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True
       Loop
Jay Freedman - 27 Jun 2005 02:58 GMT
>Can the following two loops be combined into one? I need to do
>multiple find and replace and it's taking a long time. I hope if I
[quoted text clipped - 8 lines]
>MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True
>        Loop

They can't be combined, but there's no reason to do loops, which are
just time-wasters.

Include the parameter Replace:=wdReplaceAll in each .Execute and call
it just once:

   .Execute FindText:=" <", ReplaceWIth:="<", _
       MatchWildcards:=False, Wrap:=wdFindContinue, _
       Forward:=True, Replace:=wdReplaceAll
   .Execute FindText:="(", ReplaceWIth:=vbTab + "(", _
       MatchWildcards:=False, Wrap:=wdFindContinue, _
       Forward:=True, Replace:=wdReplaceAll

--
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.