Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    Portland, Maine, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Table Navigation (Word 2003)

    This seems like it should be easy, but I can't seem to get it. I have documents with multiple tables in them. The user may be anywhere in a table and I have a button for them to add a total in the table. I need to navigate to the last row and last column of the table.

    I know how to calculate the last row number and last column number using Selection.Information(wdEndOfRangeRowNumber) and Selection.Information(wdEndOfRangeColumnNumber). However, the select command includes activedocument.tables(i) - I can't figure out how to return the table number.

    So I guess my basic question is how do I determine the table number of the current selection?

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Table Navigation (Word 2003)

    The easiest way to do this is to use Selection.Tables(1) instead of ActiveDocument.Tables(i)

    Untested air code would be something like...
    <code>If Selection.Information(wdWithinTable) Then
    With Selection.Tables(1)
    ' Manipulate the table here
    End With
    End If</code>

    StuartR

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Table Navigation (Word 2003)

    > how do I determine the table number of the current selection?

    We've had some posts about paragraphs (either on this board or on the Word board) that present the same issue. The solution was to create a range from the insertion point back to the beginning of the document, and retrieve the Count for the range's paragraphs collection. Might work for tables, too, although I always worry about embedded tables...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •