Word Automation - Performance Problem
Posted on 2011-09-30
I have just begun creating a report in Microsoft Word (2000, yes I know it's old) from data held in a VB .Net application (v2005, also becoming dated).
Things were going well until I started the second page of the report. The information here is formatted as a table, and I am populating it row-by-row with a loop like:
For intColumn As Integer = 1 To intColumns
P2TableRow.Cells.Item(intColumn).Range.Text = objaValues(intColumn - 1).ToString
After inserting a performance counter, I find that it is taking greater than 150 msec to populate each cell. Formatting statements such as:
P2TableRow.Cells.Item(intColumn).VerticalAlignment = ...
P2TableRow.Cells.Item(intColumn).Range.Bold = ...
P2TableRow.Borders.Item(Word.WdBorderType.wdBorderTop).LineWidth = ...
also take an inordinate length of time to execute.
Can anyone offer suggestions as to what might be causing this poor performance, or how to populate the table more efficiently.