![]() |
#4
|
||||
|
||||
![]()
The code in the link does work as it should - just not as you want it to. For your purposes, you could use something based on:
Code:
Sub Demo() Application.ScreenUpdating = False Dim Rng As Range Set Rng = ActiveDocument.GoTo(What:=wdGoToPage, Name:=3) Set Rng = Rng.GoTo(What:=wdGoToBookmark, Name:="\page") With Rng With .Duplicate With .Find .ClearFormatting .Replacement.ClearFormatting .Text = "in" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Execute End With Do While .Find.Found = True If .InRange(Rng) = True Then .Text = "on" .Collapse wdCollapseEnd .Find.Execute Else: Exit Do End If Loop End With End With Application.ScreenUpdating = False End Sub Code:
Sub Demo() Application.ScreenUpdating = True Dim Rng As Range Set Rng = ActiveDocument.GoTo(What:=wdGoToPage, Name:=3) Set Rng = Rng.GoTo(What:=wdGoToBookmark, Name:="\page") With Rng.Find .ClearFormatting .Replacement.ClearFormatting .Text = "in" .Replacement.Text = "on" .Forward = True .Wrap = wdFindStop .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Execute Replace:=wdReplaceAll End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] Last edited by macropod; 08-15-2014 at 03:29 AM. Reason: Alernate code |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
dirkoo | Word VBA | 2 | 08-14-2013 11:25 AM |
![]() |
Rabski | Word | 1 | 11-13-2012 02:25 PM |
![]() |
seteshpl | Word | 1 | 09-06-2011 01:35 AM |
Search Replace Copy | dblack7211 | Word | 0 | 05-05-2010 01:19 PM |
Search and Replace - Clear Search box | JostClan | Word | 1 | 05-04-2010 08:46 PM |