Access ActiveDocument in Word

Add-in Express™ Support Service
That's what is more important than anything else

Access ActiveDocument in Word
 
Daniel Heuman




Posts: 2
Joined: 2011-08-29
I'm working on an Add-In Express add-in for Word written in C#. However, I can't figure out how to access the ActiveDocument from a Custom TaskPane.

For example, I can easily access the ActiveDocument from a custom ribbon with this line:

Word.Document docToAccess = WordApp.ActiveDocument;

From that point on, I have full access to all the methods of ActiveDocument in an instance called 'docToAccess'.

However, I really want to be able to do that within a Custom Taskpane but when I use that line, it doesn't recognise the existence of WordApp. I'm sure there must be an easy solution, but I can't figure it out. Can anyone make any suggestions?
Posted 29 Aug, 2011 05:34:56 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Daniel,

Do you use Advanced Office Task Panes or Custom Task Panes?

In case of Advanced Office Task panes please check out the WordAppObj and AddinModule properties of the form class. Is it what you are looking for?
.NET, Extended MAPI, Windows Phone & RT
Posted 29 Aug, 2011 06:18:16 Top
Daniel Heuman




Posts: 2
Joined: 2011-08-29
Hi Eugene,

I meant Advanced Office Task Panes, thanks for the clarification.

Are there any examples using the WordAppObj property that way? I'm sure you're pointing me in the direction I want to go, but I'm still struggling to get access to the ActiveDocument.
Posted 29 Aug, 2011 06:57:58 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Daniel,

Please take a look at the HOWTO section of our web site. Also Add-in Express for Office and .NET sample projects are available for downloading.

FYI You just need to cast the object returned from the WordAppObj property to the Word Application class. Then you will get an access to its methods, events and properties.
.NET, Extended MAPI, Windows Phone & RT
Posted 29 Aug, 2011 07:10:49 Top