Altering format of different tables in one document

O

ouxi

I have a word document with text and many differing tables of varying
length. Most of the tables are two columns, with column one functioning
as headings for the values in column two. Occassionally, a table will
have between 3 and 5 columns, still with column 1 as headings and the
remaining columns as separate sets of values.
Is it possible to write a VBA script that will move through the
document and break up each table that is more than 2 columns into
separate tables, each of 2 columns including the heading column and its
values?

For instance, Table A
A 1
B 4
C 5
D 2

would be left alone, while Table B

A 2 5
B 2 6
C 4 9

Would be broken up into

A 2
B 2
C 4

A 5
B 6
C 9

FWIW, I'm running word x on Mac OS X 10.1.5.

Thanks for any help,
Joe
 
C

Cindy Meister -WordMVP-

Hi Ouxi,

It should be possible, yes, although no guarantees with a MAC. Let's
start with the code that will identify the tables you need to process
and see if it works on your Mac:

Dim tbl as Word.Table

For each tbl in ActiveDocument.Tables
If tbl.Columns.Count > 2 Then
tbl.Select
MsgBox "This table has " & tbl.Columns.Count & " columns."
End If
Next tbl
I have a word document with text and many differing tables of varying
length. Most of the tables are two columns, with column one functioning
as headings for the values in column two. Occassionally, a table will
have between 3 and 5 columns, still with column 1 as headings and the
remaining columns as separate sets of values.
Is it possible to write a VBA script that will move through the
document and break up each table that is more than 2 columns into
separate tables, each of 2 columns including the heading column and its
values?

For instance, Table A
A 1
B 4
C 5
D 2

would be left alone, while Table B

A 2 5
B 2 6
C 4 9

Would be broken up into

A 2
B 2
C 4

A 5
B 6
C 9

FWIW, I'm running word x on Mac OS X 10.1.5.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

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