i am creating a word (14) instance with interop out of a c# .net4 winforms application to work with a document. If some word document gets opened beyond my application the same word instance will be used an disturbs my application.
Simple question: Is there any way to set my word instance exclusive for my application?
Thanks in advance.
Btw: Found some stuff with exclusive/word/office/isolated/block/instance but no answers anyhow.
There’s sort of a solution, but it’s not pretty.
The main issue is that Word registers itself in the ROT (Running Object Table), and other applications can then easily get access to the instance of Word registered in the ROT (that’s what the VB GetObject function does for instance).
So, in your app, you’d basically have to do 2 things
Even though you terminate that first instance, It won’t “retroactively” register itself in the ROT, and other applications will generally not object a reference to it to use, they’ll automatically create a new instance, which, since no other instance is registered in the ROT anymore, will then get registered.
That said, it is still possible for other apps to get at your instance of Word, so this technique isn’t bulletproof. How? Because Word ALSO registers each loaded DOCUMENT in the ROT. But that’s a pretty seldom used feature.