Mohamed Kamal
Mohamed Kamal

Reputation: 1627

Execute word add-in on current docx file

I created Word add-in and want to execute it on the current Word file instead of using the file Path on disk. How I can refer to the Active Document ?

I'm now using the file Path like this :

string Filepath= @"D:\Word-addins\Example\Test.docx"; 

and how I can determine the Active file path to save the result on the same path ?

Upvotes: 3

Views: 765

Answers (1)

Dennis G
Dennis G

Reputation: 21788

In a word Add-In, the current document is simply ThisDocument.

You will have to generate this class yourself (as it derives from Microsoft.Office.Tools.Word.DocumentBase) as explained here:

Try to understand the Word Object Model to know how to work with text in the current document, stuff like this.Selection etc.

There is even a tutorial on how to create your first document level Add-In.

Upvotes: 1

Related Questions