Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Referencing Table Cells (Word 2003 VBA)

    I would like to reference the contents of certain table cells with bookmarks in other locations in the document. I tried the following, but since I am such a neophyte, it obviously did not work:

    ActiveDocument.Bookmarks("JobNum").Range.Text = ActiveDocument.Tables(1).Cell(Row:=2, Column:=2)

    Thank you for any help you can give!

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

    Re: Referencing Table Cells (Word 2003 VBA)

    To get the text from the table cell you can use ActiveDocument.Tables(1).Cell(Row:=2, Column:=2).Range.Text

    This will return the entire contents of the cell, including the cell marker at the end, which might not be what you want. To avoid this you may want to set a string variable equal to ActiveDocument.Tables(1).Cell(Row:=2, Column:=2).Range.Text and then remove the right hand character.

    StuartR

  3. #3
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Referencing Table Cells (Word 2003 VBA)

    Hi JeanieB,

    In addition to Stuart's suggestion, you could use a Word field (which you could insert with vba) to reference the cell. See <post#= 365442>post 365442</post#> for more details. This has the potential advantage of updating automatically if the cell contents change.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

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