Changing Paragraph Indent Margins via VBA

Hello all.

I have a macro which moves through the document based on the paragraphs collection.

It then tests the paragraph indent and changes it based on what it finds.

The problem being, the macro runs exceedingly slowly on any document that contains a table.

How would I go about excluding tables from being found and evaluated by the Paragraphs collection?

Any advice would be helpful.

Who is Participating?
You don't show your code, so it's not clear if your problem is finding the tables, or excluding them from the process.
This code will still find paragraphs in tables, but will not process them.

Sub IndentParagraphs()
    Dim para As Paragraph
    For Each para In ActiveDocument.Paragraphs
        If para.Range.Tables.Count = 0 Then
            para.Format.LeftIndent = CentimetersToPoints(3)
        End If
    Next para
End Sub
Drakos13Author Commented:
Another winner.

That works perfectly.

Thanks again!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.