Creating document from c# very slow

J

Jimmy

I am trying to create documents from a template by automating word 2003
from c# 2005 using the following code

object tpo = (object)mastertemplatepath;
object n = Missing.Value;
object f = false;
object t = true;
WordInterOp.Document letter = wd.Documents.Add(ref tpo, ref
n, ref n, ref t);

The documents.add method takes 30 seconds or so to work during which
both the visual studio development environment and the copy of the word
application (also created from c#) both hang. Once the document finally
appears the subsequent code that substitutes placeholders in the text
with particular values works fairly quickly.

Any ideas why the documents.add method is so slow and how I can speed
things up? (30 seconds will not be acceptable to the users).
 
J

Jimmy

Jimmy said:
I am trying to create documents from a template by automating word 2003
from c# 2005 using the following code

object tpo = (object)mastertemplatepath;
object n = Missing.Value;
object f = false;
object t = true;
WordInterOp.Document letter = wd.Documents.Add(ref tpo, ref
n, ref n, ref t);

The documents.add method takes 30 seconds or so to work during which
both the visual studio development environment and the copy of the word
application (also created from c#) both hang. Once the document finally
appears the subsequent code that substitutes placeholders in the text
with particular values works fairly quickly.

Any ideas why the documents.add method is so slow and how I can speed
things up? (30 seconds will not be acceptable to the users).

I have done more research into this. The slowness problem occurs even
when creating a new document from a word template icon in Windows
Explorer. Also the problem goes away when my machine is connected to
the office network.

So the problem is not to do with C# but probably with Word searching
for something on the office network, a printer perhaps.

I'll add a further post if I get this aspect fixed.

Jimmy
 

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