Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
Orsetto
 
Posts: n/a
Default VBA column width problem


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

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"

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.


--
Orsetto
  #2   Report Post  
Posted to microsoft.public.word.tables
Cindy M -WordMVP-
 
Posts: n/a
Default VBA column width problem

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 :-)

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word tables: let us make rows same width Joe Lewis Tables 13 November 16th 05 11:49 AM
Changing column width in copied text Dave Microsoft Word Help 4 August 16th 05 04:29 AM
Not your average Word column question - help! John Microsoft Word Help 6 January 11th 05 04:32 AM
Column Width propagation Cindy M -WordMVP- Tables 0 October 28th 04 06:09 PM
Can tables be permanently set to Fixed Column Width? Klaus Linke Tables 0 October 26th 04 04:27 PM


All times are GMT +1. The time now is 02:53 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"