Thread: [Solved] Text manipulation in MACRO
View Single Post
 
Old 03-10-2013, 04:31 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,385
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Having now seen what you're doing, I might add that all of the Find/Replace expressions I've provided could be rolled up into a single macro:
Code:
Sub Demo()
With ActiveDocument.Content.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchAllWordForms = False
  .MatchSoundsLike = False
  .MatchWildcards = True
  .Text = "([!^13]@^13)(*^13)([!^13]^13)([!^13]@^13)[!^13]@^13([!^13]@^13)"
  .Replacement.Text = "AN \1AC \3AH \4AL \5\2"
  .Execute Replace:=wdReplaceOne
  .Text = "(DP )([!^13]{1,})([^13]VD*VX[!^13]{1,}[^13])(DP )([!^13]{1,}[^13])"
  .Replacement.Text = "\1\2\3DB \2,\5\4\5"
  .Execute Replace:=wdReplaceAll
  .Text = "<Front[!0-9]{1,}"
  .Replacement.Text = "**French border**^p"
  .Execute Replace:=wdReplaceAll
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote