Another Jacob question. I've found that if you already have Word open when generating a document using Jacob you get problems when trying to close Word. Specifically calling
ActiveXComponent wordApp = new ActiveXComponent("Word.Application");
will open a new instance of Word. When you attempt to close this you get the error message
"This file is in use by another application or user.
(C:\Documents and Settings\...\Normal.dot)"
When you click "OK" it opens a "Save As" dialog for you to ave the Normal.dot template.
It seems that the first Word instance has a lock on the template, and the 2nd is trying to update it (not sure why) but this will cause confusion and problems for my users (especially as Word will be run with visibility off).
So my question is, is there a way to prevent this? Currently I have checked the task list to see if Word is running and give the user a message to close it but that seems a bit heavy handed. Is there a way of connecting to the existing Word instance rather than creating a new one? Alternatively is there a way of resetting the template location (to say a temp directory) to prevent the lock clash.