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 / February 2005

Tip: Looking for answers? Try searching our database.

Repeat loop until end of document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
USAFA - 16 Feb 2005 17:19 GMT
I'm trying to build a macro in Word that repeatedly performs a find action
for a particular word (e.g. "assignment") and then performs another action
afterward (e.g. adds an "s" at the end of the word "assignment").  The
problems I'm having are 1) repeating the find action and 2) having it perform
the find function and stopping when it reaches the end of the document so it
doesn't continue searching at the beginning again.

I just started working with VB, so any help would be appreciated.  
Greg - 16 Feb 2005 17:32 GMT
Sounds like you want to do a find and replace.  Try something like:

Sub Test()
Dim oRng As Range

Set oRng = ActiveDocument.Range

With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "assignment"
.Replacement.Text = "assignments"
.Execute Replace:=wdReplaceAll

End With
End Sub

If you want to pursue the "stop" further then look up "wrap" in the VBA
help.

Rate this thread:






 
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.