Find a Table

J

Jim

Tables are accessed by an integer index. Suppose I have a document with
tables that I need to update programmatically. Also, the end user is
allowed to edit the document, potentially changing the table index. Is
there any technique for locating a particular table other than by index?
(It would be pretty helpful if you could give a Table a Name or Tag value!)

TIA,
Jim
 
A

alborg

Hi Jim:

Actually, it looks like a pretty easy thing to do:

1) Place a bookmark in the table you wish to select
2) Use a statement to go to said bookmark like-

Selection.GoTo What:=wdGoToBookmark , Which:=wdGoToFirst, Count:=1,
Name:="MyBookmarkTest"

3) Now use a statement like-

If Selection.Information(wdWithInTable) Then Selection.Tables(1).Select

Bingo- not only is table located, but it is now selected and ready to be
abused...
I tried it out and the table ends up selected (i.e. blacked out).

Cheers,
Al
 
E

Ed

Bookmarks are easily destroyed by overwriting. If you are concerned
the user might edit over your bookmark, you might try adding an extra
row and put your bookmark there, then set that row height to something
like 0.01.

Ed
 
M

muyBN

Good safeguard idea from Ed. You could either do this with the extra row or
select the whole table and maybe also a paragraph mark after it then insert
the bookmark. That way the bookmark will stick around as long as the whole
table isn't deleted.
 
J

Jim

I placed a BM in Cell(1,1) and I can't delete it when working with the
table. I have to go to Insert | Bookmark and Delete there. So I'm not too
worried about accidental deletions. My users know that they edit at their
own risk.

BTW, when I select the table AND the following paragraph mark, the BM is no
longer reported as being in a table. Selecting just the table is OK.

Thanks for the tips, all.
 

Ask a Question

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. After that, you can post your question and our members will help you out.

Ask a Question

Top