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 / May 2008

Tip: Looking for answers? Try searching our database.

Search and replace a word in all pages EXCEPT the last

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dusty - 31 May 2008 18:10 GMT
Hi, I need my macro to search and replace an occurance of a word in all pages
EXCEPT the last one - can anyone help? Thanks.
Helmut Weber - 31 May 2008 20:51 GMT
Hi Dusty,

like that:

Sub Test903c()
Dim l As Long
Dim rTmp As Range
Set rTmp = Selection.Range
l = ActiveDocument.Range.Information(wdNumberOfPagesInDocument)
Selection.HomeKey unit:=wdStory
rTmp.start = Selection.start
Selection.GoTo _
what:=wdGoToPage, _
which:=wdGoToAbsolute, _
Count:=l
rTmp.End = Selection.start
rTmp.Select
With Selection.Find
  .Text = "JOHN BROWN"
  .Replacement.Text = "PAUL WHITE"
  .Execute Replace:=wdReplaceAll
End With
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
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.