Thread: [Solved] Macro help
View Single Post
 
Old 03-01-2012, 03:02 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

Hi redzan,

Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Content
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "STUDY: ([!^13]{1,})*: ([!^13]{1,})*: ([!^13]{1,})*: ([!^13]{1,})*: ([!^13]{1,})*: ([!^13]{1,})"
    .Replacement.Text = "###\1,\2,\3,\4,\5,\6"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchAllWordForms = False
    .MatchSoundsLike = False
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
    .Text = "(###[!^13 ]{1,})[ ]{1,}(*^13)"
    .Replacement.Text = "\1\2"
    .Execute Replace:=wdReplaceAll
    .Execute
  End With
  Do While .Find.Found
    .Text = Replace(.Duplicate.Text, " ", "")
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote