Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

word interop very slow

Status
Not open for further replies.

misterstick

Programmer
Apr 7, 2000
633
0
0
GB
i'm creating a document in Word from C#.

the first forty or so paragraphs are written very quickly, less than a second for all of them, but after that it slows right down to about four seconds per paragraph, and gets slower as more are added.

any ideas on how to speed things up a bit?

Code:
object nullParameter = Type.Missing;
Word._Application application = new Word.Application();
Word.Document document = application.Documents.Add(ref nullParameter, ...);
string[] paragraphs = ArbitraryArrayOfStrings();
foreach ( string paragraph in paragraphs )
{
  document.Paragraphs[document.Paragraphs.Count].Range.InsertAfter(paragraph);
  document.Paragraphs[document.Paragraphs.Count].Range.InsertParagraphAfter();
}
object fileName = passedFromElseWhere;
document.SaveAs(ref fileName, ref nullParameter, ...);
document.Close(ref nullParameter, ref nullParameter, ref nullParameter);
application.Quit(ref nullParameter, ref nullParameter, ref nullParameter);

many thanks,

mr s. <;)

 
try to run word in the background/invisible.

Code:
application.Visible = false;
 
Apllication.Visible = false" is the default.

thanks anyway.


mr s. <;)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top