Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Dec 2000
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Selecting a table (VBA/Word/97)

    Can you tell me how to begin a Word97 macro that will move the cursor to a table in a document so that I can automate some processes for the table? My problem is just beginning a macro that puts the cursor into the table automatically.
    Thanks.

  2. #2
    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: Selecting a table (VBA/Word/97)

    This is a quick and dirty; there must be a more precise way to do this; also, this is hard-coded to go to the first table:

    ActiveDocument.Tables(1).Select
    Selection.Collapse wdcollapsestart

  3. #3
    Star Lounger
    Join Date
    Dec 2000
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selecting a table (VBA/Word/97)

    Many thanks. That did it.

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Selecting a table (VBA/Word/97)

    Can't quite get that into a one-liner, but this comes close:

    ActiveDocument.Tables(1).Range.Characters(1).Selec t

    - if the cell contains text, the first character selected; else, the entire cell is selected.

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

    Re: Selecting a table (VBA/Word/97)

    Here is a one-liner for you...

    Selection.GoTo What:=wdGoToTable, Which:=wdGoToAbsolute, Count:=1

    StuartR

  6. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Selecting a table (VBA/Word/97)

    Nice! <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>

Posting Permissions

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