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

Tip: Looking for answers? Try searching our database.

how to replace text in specific area of word document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
turneg02 - 03 Aug 2005 06:51 GMT
i want to be able to replace all values of wordA with wordB but only within a
certain area of the word document. how is this done?
Graham Mayor - 03 Aug 2005 08:52 GMT
Select the text before running the replace tool and don't replace in the
rest of the document when prompted.

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> i want to be able to replace all values of wordA with wordB but only
> within a certain area of the word document. how is this done?
Helmut Weber - 03 Aug 2005 08:56 GMT
Hi,

like this:

Sub test8888()
Dim rPrg As Range
Set rPrg = ActiveDocument.Paragraphs(2).Range  ' e.g.
ResetSearch
With rPrg.Find
  .Text = "o"
  .Replacement.Text = "x"
  .Wrap = wdFindStop
  .Execute Replace:=wdReplaceAll
End With
ResetSearch
End Sub

Public Sub ResetSearch()
With Selection.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Text = ""
  .Replacement.Text = ""
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
  .Execute
End With
End Sub

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 
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.