VBA column width problem

O

Orsetto

Hi, im formatting a lot of tables using VBA.
I finally got this to work after borrowing some code here and ther
(VBA newbie here).

But I've still got a problem. Not all the tables in the document ar
the same, some have merged cells etc.
So i get the run-time error "cannot access individual columns in thi
collection because the table has mixed cell widths"

Is there a way to identify these tables using code
so i can either
- format them like the other tables
- or get them out of the code so this error won't pop-up anymore.

(I use column commands for aligning the first column to the left an
the rest to the right, and for autofit for all but the first column)
Thanks..
p.s. Why doesn't WORD allow to select all tables and apply
formatting? That is just really stupid. This allready cost me al lot o
time
 
C

Cindy M -WordMVP-

Hi Orsetto,
I finally got this to work after borrowing some code here and there
(VBA newbie here).
It would be best to address VBA questions to a word.vba newsgroup (the
.beginners group, if you're new to VBA). Chances are, you'd have already
gotten a response...
But I've still got a problem. Not all the tables in the document are
the same, some have merged cells etc.
So i get the run-time error "cannot access individual columns in this
collection because the table has mixed cell widths"
About the only thing you can do is move from cell to cell in the table,
counting the number of cells 1) in a row 2) in a column, comparing the
results. If any rows (or columns) have fewer cells, then cells have been
merged. The .Information property of the Selection / Range objects can
tell you when you're in the last cell of a row or column.

Note that what you want to do is decidedly non-trivial and not really
something for a beginner. It's actually easier to save the file as HTML
of XML (if Word 2003) and process "mixed" tables in that "pure text"
form.

Word 2002/2003 will let you select all the tables and apply
paragraph/font formatting. But only in the UI, not using VBA.
Is there a way to identify these tables using code
so i can either
- format them like the other tables
- or get them out of the code so this error won't pop-up anymore.

(I use column commands for aligning the first column to the left and
the rest to the right, and for autofit for all but the first column)
Thanks..
p.s. Why doesn't WORD allow to select all tables and apply a
formatting? That is just really stupid. This allready cost me al lot of
time.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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