i am developing some code in c# where i will be interacting with Microsoft Word. I want to be able to have the option of re-using an existing instance or as an alternative creating a new instance.
Keeping in mind i want to do all of this using LATE BINDING… it is safe to say i have figured out how to get things working when creating a new instance.. i just call Activator.CreateInstance etc..
The problem i am having is how do i reuse an existing instance, for example, Word is already open and i want to use that instance.
Is there an Activator.UseExistingInstance? or something similar??
Thanks!
You might want to have a look at the
AccessibleObjectFromWindowapi function defined in Oleacc.dll. Andrew Whitechapel has some articles on how to use it. Based on his articles I wrote an answer to a very similar question (about Excel, not Word), which you can find here:There you will find an example how to connect to an already running Excel instance and then automating this instance using late binding.
Update:
Here is a short sample adapted to Word: