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 / April 2007

Tip: Looking for answers? Try searching our database.

How to get the record macro to repeat through entire document, EOF, etc.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JB - 12 Apr 2007 21:06 GMT
Hi all:

I recorded the is macro to help me covert a file to a specific
format.  The following works but I need it to repeat through the
entire file:

Selection.Find.ClearFormatting
   With Selection.Find
       .Text = "cn=""*"""
       .Replacement.Text = "oldr"
       .Forward = True
       .Wrap = wdFindContinue
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchAllWordForms = False
       .MatchSoundsLike = False
       .MatchWildcards = True
   End With
   Selection.Find.Execute
   Selection.copy
   Selection.EndKey Unit:=wdLine
   Selection.Find.ClearFormatting
   With Selection.Find
       .Text = "newrdn:"
       .Replacement.Text = "oldr"
       .Forward = True
       .Wrap = wdFindContinue
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = False
       .MatchSoundsLike = False
       .MatchAllWordForms = False
   End With
   Selection.Find.Execute
   Selection.MoveRight Unit:=wdCharacter, Count:=1
   Selection.PasteAndFormat (wdPasteDefault)
   Repeat
End Sub

Thanks for all your help in advance!

JB
Cindy M. - 18 Apr 2007 17:27 GMT
Hi Jb,

You should find an article on the word.mvps.org site that shows
how to "loop" using Find. To summarize: you put the code in a
Do...Loop and check whether Find.Execute was successful (that
returns a boolean). If it was not, then you exit the loop.

> I recorded the is macro to help me covert a file to a specific
> format.  The following works but I need it to repeat through the
[quoted text clipped - 34 lines]
>     Repeat
> End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17
2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :-)
 
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.