How to improve performance of opening Microsoft Word when automated from c#?

Posted by Abdullah BaMusa on Stack Overflow See other posts from Stack Overflow or by Abdullah BaMusa
Published on 2010-03-20T08:18:47Z Indexed on 2010/03/20 8:21 UTC
Read the original article Hit count: 179

Filed under:
|
|

I have Microsoft Word template that I automated filling it’s fields from my application, and when the user request print I open this template. but creating word application every time user request print after filling fields is very expensive and lead to some delay while opening the template, so I choose to cache the reference to Word then just open the new filled template. that solve the performance issue as opening file is less expensive than recreating Word each time, but this work while the user just close the document not the entire Word application which when happened my reference to Word become invalid and return with exception says: “The RPC server is unavailable” next time request opening template . I tried to subscribe to BeforClosing event but his trigger for Quitting Word as well as Closing documents. My question is how to know if the word is closing document or quit the entire application so I take the proper action, or any hint for another direction of thinking about improve performance of opening word template.

© Stack Overflow or respective owner

Related posts about c#

Related posts about microsoft-word