![]() |
#1
|
|||
|
|||
![]() I want to apply a condition to the replacement. I want "ea" to be replaced by "2" only when "ea " is not the first or last letters of the word that contains it. 1. How do I apply this condition? 2. How do I get the find and replace to stop when the end of document is reached? Note: In Braille, the code for "ea" is "2" in a word document. Help would be greatly appreciated. Norman Sub FindAndReplaceEAwith2() ' ' Find and Replace "ea" with "2" Macro ' Macro recorded 31/7/15 by NG ' On Error GoTo StopMacro Set oRng = ActiveDocument.Range oRng.HighlightColorIndex = wdNoHighlight oRng.Find.ClearFormatting oRng.Find.Replacement.ClearFormatting oRng.Find.Replacement.Highlight = True For i = 1 To 20 With oRng.Find .Text = "ea" .Replacement.Text = "2" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With oRng.Find.Execute Replace:=wdReplaceOne MsgBox (oRng.Characters.First.Previous) Next i StopMacro: Stop End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
QA_Compliance_Advisor | Word VBA | 11 | 09-11-2014 11:51 PM |
![]() |
Hoxton118 | Word VBA | 7 | 06-10-2014 05:05 AM |
![]() |
ubns | Word VBA | 1 | 05-02-2012 12:52 AM |
![]() |
paulkaye | Word | 4 | 12-06-2011 11:05 PM |
![]() |
shabbaranks | Excel | 4 | 03-19-2011 08:38 AM |