the index numbers of the tables in a word document

K

Ken

Hi,

I have a word template that was created by the third
party. I would like to insert data to the tables in the
template from a text file. There are 3 tables on the
template but when I check from my VBA code. I use
ActiveDocument.Tables().Count. The number shows up "2".

My questions are:
1. What happened to 3 tables in my template. Why I only
have 2 index numbers for 3 tables?

2. My VBA code can insert data to the table in the
template by using Tables(1) or Tables(2). But, it always
goes to the same table in the template. I am wondering
does those indexes are linked to a specific table. If
there is any way I can write to let my data insert to the
table I want.

Thank you very much! I appreciated it!
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Ken,

One of the tables is not in the main storyrange of the document - probably
in a header or footer

You will need to reference the .Range in which it is located.

e.g.
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Tables(1)

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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