Consulting

Results 1 to 6 of 6

Thread: Solved: Tables In Word Query

  1. #1
    VBAX Regular
    Joined
    Apr 2005
    Posts
    86
    Location

    Solved: Tables In Word Query

    Hey guys,

    A bit of advice if you may.... When telling VBA to delete certain tables, i have to tell it the number of the table that i wish to delete.
    This is causing me quite a few problems because this number is always different.
    For example, i may tell vba to delete table(6) but occasionally a table before this doesnt exist and so it becomes table(5).
    Is there a way of naming your tables so that you can refer to them easily??

    Many Thanks

    Pete

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi Pete,

    Depends on what you find easy?

    All possibillities are listed in this simular topic:
    http://www.vbaexpress.com/forum/showthread.php?t=3512

    Enjoy!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  3. #3
    VBAX Regular
    Joined
    Apr 2005
    Posts
    86
    Location
    Thanks Joost, that'll do me

  4. #4
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    No, unfortunately there is not really.

    However, that being said, there is a way to get around it. It depends on your requirements.

    As you have discovered Tables(6).Delete will delete the sixth table (regardless of whether it is the correct one) OR give an error because there is only five now (as an example).

    The easiest solution is to bookmark your tables. Select the whole table, give it a bookmark. Now if you want to delete it (or select it, or whatever), you can reference directly, as a bookmark. Such as:

    ActiveDocument.Bookmarks("Table6").Delete

    Just remember that in the above example, "Table6" is a name. If you selected the first table and named its bookmark as Table6....then that would be its name.

    So say you have a table of, I don't know, client names and addresses. Make it a bookmark named ClientInfo. You can now reference it, action it, as a bookmark.

  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Glad to here...Ps...take on Gerry's advice!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  6. #6
    VBAX Regular
    Joined
    Apr 2005
    Posts
    86
    Location
    Make it a bookmark, of course!! I can't believe i didnt think of that

    Thanks Gerry

Posting Permissions

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