Thread: [Solved] Text manipulation in MACRO
View Single Post
 
Old 03-10-2013, 02:56 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,384
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

You're still working with selections, though - your next meaningful step is:
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Quote:
And I need to run this Macro only once.
It seems to me that writing the macro would've taken much longer than doing the job manually. Unless you need to do this on multiple documents, there'd be a negative ROI.

That said, you can still do it with Find/Replace, by deleting the 'CTR', though typing the expression each time might be tedious - as well as being error-prone. As a macro, the F/R becomes:
Code:
Sub Demo()
With Selection
  .HomeKey Unit:=wdStory
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "([!^13]@^13)(*^13)([!^13]^13)([!^13]@^13)[!^13]@^13([!^13]@^13)"
    .Replacement.Text = "AN \1AC \3AH \4AL \5\2"
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute Replace:=wdReplaceOne
  End With
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote