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
    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
    .Cells(.Cells.Count).Select
    End With
    Selection.SplitTable
    Selection.MoveDown
    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) & "t-online.de"
     
    Helmut Weber, Apr 13, 2007
    #2
    1. Advertisements

  3. survivor

    Tony Jollans Guest

    I *think* this should always work:

    <table_ref>.Range.Cells(1).Range.Rows.LeftIndent

    --
    Enjoy,

    Tony Jollans
    Microsoft Word MVP

    "survivor" <> wrote in message
    news:...
    >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)
    >
     
    Tony Jollans, Apr 13, 2007
    #3
  4. survivor

    survivor Guest

    Less than ideal but it works. A clever trick but, as you mentioned, good as
    a workaround. Thank you

    "Helmut Weber" <> wrote in message
    news:...
    > Hi Survivor,
    >
    > just a workaround, if there is no better solution,
    > split the table temporarily, like:
    >
    > Sub testx23()
    >
    > With Selection.Tables(1).Range
    > .Cells(.Cells.Count).Select
    > End With
    > Selection.SplitTable
    > Selection.MoveDown
    > 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) & "t-online.de"
     
    survivor, Apr 13, 2007
    #4
  5. survivor

    survivor Guest

    This works on my document. Thank you. Not intuitive though

    "Tony Jollans" <My forename at my surname dot com> wrote in message
    news:%...
    >I *think* this should always work:
    >
    > <table_ref>.Range.Cells(1).Range.Rows.LeftIndent
    >
    > --
    > Enjoy,
    >
    > Tony Jollans
    > Microsoft Word MVP
    >
    > "survivor" <> wrote in message
    > news:...
    >>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 13, 2007
    #5
  6. survivor

    RAK_da_Pira

    Joined:
    Mar 2, 2016
    Messages:
    1
    Likes Received:
    0
    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)

    Perplexing!!

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

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.
Similar Threads
  1. Esteban

    Find.Replace() Indent to Tab.

    Esteban, Oct 17, 2003, in forum: Word VBA
    Replies:
    3
    Views:
    3,078
    Klaus Linke
    Oct 21, 2003
  2. Jonathan Wareham

    Hanging Indent With Word Automation

    Jonathan Wareham, Nov 25, 2004, in forum: Word VBA
    Replies:
    1
    Views:
    421
    Helmut Weber
    Nov 25, 2004
  3. David Cleave

    Tables: indent from left

    David Cleave, Jan 26, 2006, in forum: Word VBA
    Replies:
    2
    Views:
    2,535
    David Cleave
    Jan 26, 2006
  4. JWS315
    Replies:
    8
    Views:
    187
    Tony Jollans
    Mar 1, 2006
  5. MichaelB

    Table indent question

    MichaelB, Mar 20, 2006, in forum: Word VBA
    Replies:
    1
    Views:
    164
    Helmut Weber
    Mar 20, 2006
  6. andreas
    Replies:
    0
    Views:
    176
    andreas
    Dec 8, 2006
  7. jeldard

    VBA End Hanging Indent

    jeldard, May 5, 2007, in forum: Word VBA
    Replies:
    1
    Views:
    223
    Doug Robbins - Word MVP
    May 5, 2007
  8. Dan Neely

    Regularize indent level

    Dan Neely, Oct 30, 2007, in forum: Word VBA
    Replies:
    2
    Views:
    113
    Dan Neely
    Oct 30, 2007
Loading...