Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files from any .NET platform (C#, VB.NET, ASP.NET, .NET Core) and Java applications (J2SE and J2EE) with fast and high quality performance.

Tue Jul 02, 2019 8:21 am

Hello,

i am new to this product and have a question, is it possible to use Spire Doc with a visual studio Word Add-in project?

if yes, how do i reference the active document?

in MS interop i used to use: Globals.ThisAddIn.Application.ActiveDocument

Thanks and Regards

aluay
 
Posts: 3
Joined: Tue Jul 02, 2019 8:17 am

Tue Jul 02, 2019 10:20 am

Hi aluay,

Thanks for your inquiry.
Our Spire.Doc could be used in Word Add-in.
As far as I know, the function "Globals.ThisAddIn.Application.ActiveDocument" is used for getting the document. There is no same method in Spire, but you could load the document via file stream or file path. Then operate the file.
Code: Select all
            Document doc = new Document();
            //get file via file stream
            doc.LoadFromStream(FileStream);
            //get file via file path
            doc.LoadFromFile(@"filePath");


Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Jul 02, 2019 10:55 am

Thanks for the reply.

but as an Add-in, i am within the document that i want to edit, i dont know the file name or path for it.

aluay
 
Posts: 3
Joined: Tue Jul 02, 2019 8:17 am

Wed Jul 03, 2019 8:10 am

Hi,

Thanks for your response.
I think you could use the method like Globals.ThisAddIn.Application.ActiveDocument.FullName to get the file name, then load the file with Spire.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Jul 03, 2019 10:00 am

thanks a lot , this should work

aluay
 
Posts: 3
Joined: Tue Jul 02, 2019 8:17 am

Wed Jul 03, 2019 10:12 am

Hi,

If there is any question, welcome to contact us.
Have a nice day!

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.Doc

cron