How to determine Table Indent

Discussion in 'Word VBA' started by survivor, Apr 12, 2007.

  1. survivor

    survivor Guest

    I used to use Table.Rows.LeftIndent property to determine a table's indent
    value. If this is value was set to wdUndefined then usually
    Table.Rows(0).LeftIndent is the most appropriate since some documents tend
    to indent all other rows slightly to enhance the appearance. I have found
    that some tables have vertically merged cells so individual rows cannot be
    accessed. However, Word reports the correct value from the Table Properties
    menu. Is there a way to obtain the indent value in VBA under these
    conditions? (Table.Rows.Leftindent returns wdUndefined and the table has
    vertically merged cells)
    survivor, Apr 12, 2007
    1. Advertisements

  2. survivor

    Helmut Weber Guest

    Hi Survivor,

    just a workaround, if there is no better solution,
    split the table temporarily, like:

    Sub testx23()

    With Selection.Tables(1).Range
    End With
    MsgBox Selection.Tables(1).Rows(1).LeftIndent
    ActiveDocument.Undo 1
    End Sub

    Greetings from Bavaria, Germany

    Helmut Weber, MVP WordVBA

    Win XP, Office 2003
    "red.sys" & Chr$(64) & ""
    Helmut Weber, Apr 13, 2007
    1. Advertisements

  3. survivor

    Tony Jollans Guest

    I *think* this should always work:

    Tony Jollans, Apr 13, 2007
  4. survivor

    survivor Guest

    Less than ideal but it works. A clever trick but, as you mentioned, good as
    a workaround. Thank you
    survivor, Apr 13, 2007
  5. survivor

    survivor Guest

    This works on my document. Thank you. Not intuitive though
    survivor, Apr 13, 2007
  6. survivor


    Mar 2, 2016
    Likes Received:
    The following also works for reading the .LeftIndent property of tables with (vertically) merged cells:

    <table ref>.Cell(1, 1).Range.Rows.LeftIndent

    But to set the LeftIndent for the whole table, you have to use:

    <table_ref>.Range.Rows.LeftIndent = value_in_points

    (use of <table ref>.Cell(1, 1).Range.Rows.LeftIndent = value_in_points sets a left indent for row 1)


    Richard (from Piracicaba, SP, Brazil)
    RAK_da_Pira, Mar 2, 2016
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.