Access ActiveDocument in Word

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

Access ActiveDocument in Word
 
Daniel Heuman


Guest


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


Guest


Hi Daniel,

Do you use http://www.add-in-express.com/add-in-net/office-task-panes.php or http://msdn.microsoft.com/en-us/library/aa942864%28v=vs.80%29.aspx?

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?
Posted 29 Aug, 2011 06:18:16 Top
Daniel Heuman


Guest


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


Guest


Hi Daniel,

Please take a look at the http://www.add-in-express.com/support/addin-c-sharp.php section of our web site. Also http://www.add-in-express.com/downloads/adxnet.php 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.
Posted 29 Aug, 2011 07:10:49 Top