Adding row to table is Slooooooow! 
Author Message
 Adding row to table is Slooooooow!

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



Tue, 17 Sep 2002 03:00:00 GMT  
 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



Wed, 18 Sep 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. adding a table row, without setting same defaults as previous row

2. row heights of table rows added by vba

3. How to Create 2 column table and continue adding rows

4. Format of Rows Added to a Table

5. Adding Rows to a Table

6. add text to table rows

7. Running a macro to add a row in a table

8. Add row to the end of a table

9. Adding new rows to related tables on a dataset

10. Help adding Table Rows dynamically Please!

11. Adding blank row in table

12. Trouble Adding a row to a table - runtime

 

 
Powered by phpBB® Forum Software