Loop Macro

From Fxp Wiki

Jump to: navigation, search
 
Sub Macro15()
 
Dim rng As Range
Dim p As Paragraph
 
For Each p In ActiveDocument.Paragraphs
Set rng = p.Range
    rng.Find.ClearFormatting
    With rng.Find
        .Text = "^t"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
    End With
    If rng.Find.Execute Then
        rng.MoveStart wdParagraph
        rng.MoveStart wdCharacter, -1
        rng.InsertBefore Text:="xxx"
    End If
Next p
 
End Sub
 

Credits

  • Martin Sägesser and Jonathan West for their help on microsoft.public.word.word97vba (actually, a total rewriting of my original macro by Martin Sägesser :-) )
Personal tools