Macro for breaking up tables

J

Joe

The data files in Word each have around 50 tables of 2 to 5 columns and
a 8 to 20 rows. In each table, the first column always contains labels.

For example:
Record1 Record2
Label1 4 2
Label2 5 4
Label3 Blue Red

I'd like to get a macro that goes through the current document and
breaks up every table with more than 2 columns. Ideally, it would
remove each column beyond column 2 and attach it to the labels column
to be inserted as sepeate tables following the original.

For example:
Record1
Label1 4
Label2 5
Label3 Blue

Record2
Label1 2
Label2 4
Label3 Red

Ultimately, I'd like all tables to also be converted to tab delimited
text. Can anyone show me and example of such a macro.

Thanks,
Joe
 
C

Cindy M -WordMVP-

Hi Joe,

which version of Word do you have?
The data files in Word each have around 50 tables of 2 to 5 columns and
a 8 to 20 rows. In each table, the first column always contains labels.


I'd like to get a macro that goes through the current document and
breaks up every table with more than 2 columns. Ideally, it would
remove each column beyond column 2 and attach it to the labels column
to be inserted as sepeate tables following the original.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 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 :)
 
J

Joe

I am using Word:Mac v.X

This snippet someone helped me with actually finds the tables:

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

but don't know how to proceed from there.

Thanks,
Joe
 
C

Cindy M -WordMVP-

Hi Joe,

I'm sorry, things got busy and I've been away off and on; just never
got to this group the last few weeks. Do you still need help with
this?
This snippet someone helped me with actually finds the tables:

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

but don't know how to proceed from there.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30
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