tables in tables very slow

T

tomk20

I'm generating a document in VBA that reads data from a database and then creates a document. I have 5-6 levels of nested tables necessary to format the data. The resultant document is about 100 pages. The generation of the document and formatting of the tables takes 9+ hours to complete on a P4/512MB. Needless to say this will not be acceptable. When I single step thru some of the formatting commands (like setting up borders and bolding text) I can see it takes several seconds for each command. What can I do to improve speed?
 
J

Jezebel

Some suggestions --

1. Work entirely with Range objects (never the Selection object).
2. Instead of applying formatting (like applying borders and bolding text),
predefine styles in the template you're using, then apply those.
3. Work with the document hidden (so Word doesn't need to repaginate it
repeatedly).
4. Use With ... End With constructions to set multiple properties of the
same object, rather than setting them individually.



tomk20 said:
I'm generating a document in VBA that reads data from a database and then
creates a document. I have 5-6 levels of nested tables necessary to format
the data. The resultant document is about 100 pages. The generation of the
document and formatting of the tables takes 9+ hours to complete on a
P4/512MB. Needless to say this will not be acceptable. When I single step
thru some of the formatting commands (like setting up borders and bolding
text) I can see it takes several seconds for each command. What can I do to
improve speed?
 
K

Klaus Linke

Hi Tom,

Most importantly: Keep the tables short.
If some of your tables should span several pages, that'll kill Word.

"5-6 levels of nested tables" sounds rather weird... Never have seen
anything like it.
Is this really necessary? I've never seen any need for nested tables,
though some of the tables I do are very complex.

Regards,
Klaus
 
D

DA

In addition to the comments from Jezebel, I'd also make
sure you're clearing your Undo buffer on a regular basis
(e.g. ActiveDocument.UndoClear).

I agree with Klaus that nesting tables to 5 or 6 levels
seems overkill. I feel that any code optimization methods
will still not yield you the performance you're after.
It's a great product, but unfortunately we all know you
can only stretch Word so much before the seams start
bursting..

Best of luck,
Dennis.
-----Original Message-----
I'm generating a document in VBA that reads data from a
database and then creates a document. I have 5-6 levels
of nested tables necessary to format the data. The
resultant document is about 100 pages. The generation of
the document and formatting of the tables takes 9+ hours
to complete on a P4/512MB. Needless to say this will not
be acceptable. When I single step thru some of the
formatting commands (like setting up borders and bolding
text) I can see it takes several seconds for each
command. What can I do to improve speed?
 

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