
Adding row to table is Slooooooow!
Hi Ross,
How about determing the number of records in the recordset, then adding the
table from scratch with the required number of rows/columns ? Inserting a 3
column, 20,000 row table into a document took 2 seconds on my P300 machine !
If you absolutely have to append rows, just move the insertion oint to the
line below the table and add another table with the required number of rows.
This is very fast and the added table is incorporated into the original
table ie: running
MsgBox ActiveDocument.Tables.Count
will return 1, no matter how many times this is done. As a last resort, you
could add each individual row by adding a 3 column, 1 row table rather than
using InsertRows. As I said before, if you add the "new table" just below
the existing one, it will be incorporated into the existing one.
--
Hope this helps.
Regards
ibby
Please post replies or follow-ups to the **newsgroup** so that participants
may benefit or contribute.
Quote:
> I'm working on creating a price catalog for a client. I use ADO to
generate
> a recordset off of a SQL Server 7 view. There are 21,500 rows in the view
> and the joins are performed over there.
> There are 3 cells in the table. One is Product Code, two is Full
> Description, and 3 is price.
> I'm trying to do this in VBA because I want to do some manipulation of
> output on the Full Description cell by bolding the first word when there
is
> a change of product category.
> The retrieval of the recordset takes an acceptable amount of time, maybe 3
> to 5 seconds. Then it's just Do While Not .EOF......
> In tracing it looks like all the calls to the Word Object are time
> consuming, especially the Selection.InsertRowsBelow 1. I tried this also
> with getting the count of the recordset as Z and doing
> Selection.InsertRowsBelow Z. This took 16 minutes for the 21,500 records
> with CPU usage at 100% the whole time. The update of cells in that
scenario
> was even slower!!!
> Does anyone know what properties I need to set to get performance similar
to
> a standard mail merge? After all, that is also inserting rows into a table
> (it's set up as a Catalog) and inserting text into the cells.
> We can go back to the original mail merge but the formatting of the Full
> Description cell would really make the client happy.
> Thanks in advance,
> Ross