word VBA - Merging two tables

S

Sebastian

Hello VBA checkers,

i wrote a word2000 macro, where i have to put two tables together. The
problem is that the second table can have one more column than the
first. I just want to glue both tables together to one.
The following code does this job, but it is very slow. I'd like to
connect two tables with over 1000 rows:


'add one row, on this row the new ones are added
firstTable.Rows.Add

For Each row In secondTable.Rows

firstTable.Rows(firstTable.Rows.Count).Range.FormattedText =
row.Range.FormattedText

Next

'remove last row, its empty
firstTable.Rows(firstTable.Rows.Count).Delete


Did someone knows a better, and faster way to do this job?


Thanks, in advance

Sebastian
 
H

Helmut Weber

Hi Sebastian,

I wonder,

as here and now, 2 tables, one with 5 columns
and another one with 4 columns,
seperated e.g. by an empty paragraph,
will merge without any problem,
just by removing what seperates them.

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 

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