Word 2010 - VBA to add blank line before every number RRS feed

  • Question

  • Hello all,

    Can VBA insert a blank line before every integer in a document?  So that each integer, and following text, would be left justified?

    Thank you!

    Thursday, December 20, 2012 10:09 PM

All replies

  • You can perform a wildcard search for <([0-9]) and replace with ^p\1

    In VBA:

    Sub InsertBlankBeforeNumber()
        With ActiveDocument.Content.Find
            .Text = "<([0-9])"
            .Replacement.Text = "^p\1"
            .Forward = True
            .Wrap = wdFindStop
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchAllWordForms = False
            .MatchSoundsLike = False
            .MatchWildcards = True
            .Execute Replace:=wdReplaceAll
        End With
    End Sub

    Regards, Hans Vogelaar

    Thursday, December 20, 2012 10:32 PM