Word 2003: Consistent Left Indent

Soldato
Joined
28 Dec 2003
Posts
3,699
Location
Aberwristwatch
I've got a Word file with hundreds of paragraphs of indented text. I want to change them all to be 1cm. I can do this manually via the Find function but it's going to take hours. Any way of scripting it so that say any left indent greater than 0.1cm is changede to 1cm

Thanks!
 
Soldato
Joined
25 Oct 2002
Posts
2,627
You can definitely do this easily with a VBA macro.

With your document open go to the Developer tab, and click Visual Basic. In the left hand side double click in ThisDocument and paste the following. You can then just press F5 to run the code against the currently open document.

This will change all left indents greater than 0.1cm to 1cm
Code:
Sub adjustIndent()

    Dim p As Paragraph
    
    For Each p In Word.ActiveDocument.Paragraphs
    
        '   Word VBA uses points as the unit of measurement, you can use CentimetersToPoints to convert to this
        If p.LeftIndent > CentimetersToPoints(0.1) Then
        
            p.LeftIndent = CentimetersToPoints(1)
        End If
    Next p

    MsgBox "Complete", vbInformation + vbOKOnly

End Sub

If you only want the first line indented change p.LeftIndent to p.FirstLineIndent
 
Back
Top Bottom