Slow VBA Word after installing Windows XP Service Pack 2

E

Ergun

I have a VBA/Word application written under .NET framework 1.1 accessing
Microsoft Word 9.0 Object Library through COM interoperobility layer. This
application performed well until Windows XP Service Pack 2 is installed. Now
it performs poorly and nearly 8-10 X slower accross all Word calls. That is,
not just one particular function call through COM interoperob is slower, but
seems like ALL Word functions are running much slower consistently (this has
been proved with intensive tracing). In a nutshell the application renders
tables and colorizes rows or cells using code like:

Word._Document doc = (Word._Document)rc.Document;

Word.Range range = (Word.Range)rc.Range.Range;

Word.Table wt = null;

wt = range.ConvertToTable(
ref seperator,
ref numrows,
ref numcols,
ref initialcolwidth,
ref format,
ref applyBorders, // Apply borders
ref applyShading, // Apply Shading
ref applyFont, // Apply Font
ref applyColor, // Apply Color
ref applyHeading, // Apply Heading Rows
ref falseVal, // Apply Last Row
ref falseVal, // Apply First Column
ref falseVal, // Apply Last Column
ref falseVal, // AutoFit
ref afitbvor, // AutoFit Behaviour
ref tabbvor ); // Default Table Behaviour

wt.Select();
Word.Selection sel = doc.Application.Selection;

sel.Tables.Item(1).Cell( 1, 1).Select();
sel.SelectRow();
sel.Cells.Shading.BackgroundPatternColor = (Word.WdColor)par.Color;

Great care was spent to make the code efficient using word table rendering
techniques given in MVP site :

(http://word.mvps.org/FAQs/TblsFldsFms/FastTables.htm).

Stopping disabling the Virus check program or various other services by
elimination didn't make any difference.

I suspect .NET Framework SP 1 which came with KB867460 (and which is now
included in Windows XP Service Pack 2) could also have played part in this.

My hunch is something to do with a combination of COM Interoperob layer and
additional security checks/fixes introduced in the service pack causing
perhaps dubious retries or timeouts somewhere.

Thanks in advance..
 
E

Ergun

This is turned out to be a false alarm. I found an XP SP2 machine and Interop
runs very fast (100 rows table is rendered in 600ms), whereas on some XP SP2
machines the same test takes about 6s. I suspect something to do with Interop
performance related to security (above two machines had different domains).
Used SuppressUnmanagedCodeSecurityAttribute in the Interop libraries (i.e.
built with tlbimp \unsafe switch), didn't make any difference. Problem
persists. Any help will be appreciated.
 

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