What is the best way to make a static reference to a cell in word

A

Arlan

As bookmarks are possible to erase as a word table cell is edited (Thanks for
the info Jay!) what is a good alternative to create a static reference to
particular cells in a word table? Or is there one?
 
J

Jay Freedman

Well, there isn't one in the general case, but you may be able to do
something for the specific case if you can define some criterion to
identify the right location.

The criterion is going to depend critically on how your template is
constructed and what you let your users do. If the template creates a
protected form, you can be pretty sure (unless your users are the
destructive hacker type) that they aren't going to add or delete
tables, so you could use a reference like
ActiveDocument.Tables(3).Cells(2,3).Range. Or you could try enclosing
the entire table in a bookmark, which is less likely to be
accidentally deleted, and then refer to
ActiveDocument.Bookmarks("MyTable").Tables(1).Cells(2,3).Range.

If you can't do something like that, maybe there's a constant
table-column heading that you can use as the search text in a .Find
operation. If you find it, then navigate the table from there.

Whatever scheme you use, be sure to error-trap your code to handle (as
gracefully as possible) the case when you can't locate the right cell.
 
J

Jezebel

Good points. Other methods --

-- Using the Table's ID property to link to additional information in a
collection class. You have to reconstruct the collection each time you open
the document, since table IDs aren't saved.

-- Putting a tag, as hidden text, in the table header.

As you suggested last time, it would be a lot easier to make suggestions if
we had some guidance as to the point of the exercise.
 

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