none
Word 2010 - Macro to ident paragraphs to match Heading indents? RRS feed

  • Question

  • VBA Superstars - Please Help.  I have a 1500 page document  in which I used wild-card Find and Replace strings to identify all headings throughout the document through to Heading 9.  Each heading has an increased indent.


    Problem: How can I select the text between the headings (often more than one paragraph) and set the paragraph indent to match the heading selection?  In other words, how can I make my document's paragraph formatting appear like it does in the outline view?
    Any help would be greatly appreciated.  I have been losing sleep.  I need to make it look like the following:

    Heading 1
    Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.


        Heading 2
        Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text.   TexText. Text. Text.Text. Text. Text.Text.   

            Heading 3
            Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text.
                Heading 4 

                 Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text.  Text. Text.Text. Text. Text.Text. Text. Text.Text. Text.
    Heading 1
    Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.Text. Text. Text.


    Wednesday, June 29, 2011 5:20 PM

Answers

  • Try:

    Sub ScratchMacro()
    'A quick macro scratch pad created by Greg Maxey
    Dim oPar As Paragraph
    For Each oPar In ActiveDocument.Range.Paragraphs
      If oPar.OutlineLevel > 9 Then 'Which means it isn't an outline level paragraph
        oPar.FirstLineIndent = oPar.Previous.FirstLineIndent
      End If
    Next oPar
    End Sub


    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm
    Wednesday, June 29, 2011 9:51 PM