This project has moved and is read-only. For the latest updates, please go here.

How to grab the activeDocument of a running instance

Mar 30, 2012 at 11:28 AM
Edited Mar 30, 2012 at 11:32 AM

Hi

How can I grab the current running instance of Word to get an reference for the actice document.

I do not want to create a new application in netoffice, beacuse the user has Word already running. Is there a way to attach the running instance to netoffice, to grad the activedocument from there?

The word was not created through netoffice!

 

thanks

Mar 30, 2012 at 5:32 PM
Edited Mar 30, 2012 at 5:34 PM

hello,

this is an example code snippet:
 

// Initialize NetOffice
LateBindingApi.Core.Factory.Initialize();

object wordProxy = System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
Word.Application wordApplication = new Word.Application(null, wordProxy);

//
// do all the things here
//

wordApplication.Dipose();
 


an advanced exemplary workflow is available in the examples. Misc\GetRunningOutlookInstance

Sebastian