none
Line by Line Left Indent greater than or equal to the line before it - VBA MS Word Macro RRS feed

  • Question

  • I'm trying to create a macro that goes throgh each line and makes sure that any line that has an indent of 0 has an indent greater than or equal to the indent of the line before it. If it is not greaterthan or equal to the line before it, I want the indent to be equal to the previous line.

    I've found Selection.Paragraphs.LeftIndent is the code that I need to work with but I'm not good at constructing simple code like this without an example of how to do it. I was thinking a "For each oPara In ActiveDocument.Paragraphs" loop but unsure on how to actually code it.

    Dim oPara As Object
    
    For Each Para In .Paragraphs
    
       If Para.Paragraphs.LeftIndent = 0 Then
           get paragraph indent of the previous paragraph
           If then comparitive indent statment
               make the current paragraph = to previous Para
           End If
       End If
    Next
    

    Here's an example of what I'm working with. Sorry, it won't let me post a hyperlink. "(dot)" to "."

    dl.dropboxusercontent(dot)com/u/22523394/Indent%20Example%20.docx

    Tuesday, May 6, 2014 11:55 AM

All replies

  • Looking at your sample...

    Do you want this document to be formatted with Heading styles and/or Word's automatic numbering? Or is this all and always "plain text" (and does it need to be plain text)?


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, May 6, 2014 3:30 PM
    Moderator
  • I need the text that's not part of the numbering to be in line with the text that is numbered. I need to keep the numbering but this specific text is an exception and just needs to be visually in line with the text above it.
    Wednesday, May 7, 2014 6:23 PM
  • Hi Ryan

    It would help us help you if you would reply to my questions, rather than reiterate what it is you want...

    What you're asking is - if we can't leverage Word's built-in tools - not a simple task. Easy to formulate what you want, but not so easy to realize!


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, May 8, 2014 9:18 AM
    Moderator