M
Martin Pozor
I am creating software using c# which silently opens word document, saves it
to some location and closes it. It uses
Microsoft.Office.Interop.Word.ApplicationClass, so new winword.exe process
(hidden to user) is launched and after operation completes, process is closed.
This works fine with Word 2003. With Word 2007 it works as well, but there
is one problem. Instantiating Word ApplicationClass fails when 2 conditions
are met: another winword.exe instance is running (user has already some
document opened) and there is some dot or dotx template in Word startup
folder. In that case, Word shows message, that this template is locked for
editing by first instance of Word and therefore cannot be loaded when
launching sencond winword.exe instance. I remind, Word 2003 has no problem
with this situation, problems occurs only in 2007.
I will really appreciate any try to help me.
But please, don't tell me, that only solution is using
Marshal.GetActiveObject("Word.Application") and reusing already running
winword.exe process in that situation. I already tried that, it works, but
there are many consequent problems: for example it doesn't work when some
modal dialog is just shown in Word, there are also problems with hidden
winword.exe process which is used in Outlook 2003 for html email editing and
other. Simply, I have good reasons to want to keep this functionality
isolated in separate winword.exe process.
So is there any way of achieving similar behavior of Word 2007 like Word
2003. How to avoid "xxx.dot is locked for editing" message?
Thank you very much.
to some location and closes it. It uses
Microsoft.Office.Interop.Word.ApplicationClass, so new winword.exe process
(hidden to user) is launched and after operation completes, process is closed.
This works fine with Word 2003. With Word 2007 it works as well, but there
is one problem. Instantiating Word ApplicationClass fails when 2 conditions
are met: another winword.exe instance is running (user has already some
document opened) and there is some dot or dotx template in Word startup
folder. In that case, Word shows message, that this template is locked for
editing by first instance of Word and therefore cannot be loaded when
launching sencond winword.exe instance. I remind, Word 2003 has no problem
with this situation, problems occurs only in 2007.
I will really appreciate any try to help me.
But please, don't tell me, that only solution is using
Marshal.GetActiveObject("Word.Application") and reusing already running
winword.exe process in that situation. I already tried that, it works, but
there are many consequent problems: for example it doesn't work when some
modal dialog is just shown in Word, there are also problems with hidden
winword.exe process which is used in Outlook 2003 for html email editing and
other. Simply, I have good reasons to want to keep this functionality
isolated in separate winword.exe process.
So is there any way of achieving similar behavior of Word 2007 like Word
2003. How to avoid "xxx.dot is locked for editing" message?
Thank you very much.