none
Problems in adding Word add-ins dynamically to Word through ASP.NET RRS feed

  • Question

  • Hi,

    I have implemented adding word add-ins (that comes with MS Word 2013 SP1) to Word document dynamically in ASP.NET. I am using Office 2013 Open office SDK API's to achieve that. There are API's available like WebExtensionPart, PartContent. So i am getting my required Word document bytes and using Open Office SDK API's i am adding add-ins with the Word and launching it in ASP.NET.

    Everything works fine if i have only one instance of Word. If i have one instance of word opened and if i try to open word for the second time programatically , the add-ins getting added in first instance of opened word and my new word instance doesn't have that add-in (where the expected outcome was to have add-ins on newly opened word).

    So please can some one help me in knowing solution for this.

    Regards,

    Dhinesh

    Monday, April 17, 2017 5:50 AM

All replies

  • Hello Dhinesh,

    What add-in do you developing? COM/VSTO Add-ins or Office Add-ins(using Office JavaScript API)?

    How do you develop the add-in? How do you use Open XML library in your add-in?

    According to Considerations for server-side Automation of Office, Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    So it does not recommend and support to develop COM/VSTO add-ins in ASP.NET.

    If you are developing with Office JavaScript API, what code do you use?

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, April 18, 2017 2:30 AM
    Moderator
  • Hi Celeste,

    I am developing Office Add-ins(using Office JavaScript API). The add-ins are generated and appended in word document using c# code. The way i launch is through ASP.NET MVC. The sample code is shown below,

    Main code block to open Word document:

    const string contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
                        var doc = FetchWordBytes();
                        doc = AddTaskPane(doc);
                        return new FileContentResult(doc, contentType);

    AddTaskPane method to add word add-ins :

    public byte[] AddTaskPane(byte[] doc)
            {
                using (var docStream = new MemoryStream())
                {
                    docStream.Write(doc, 0, doc.Length);
                    using (var wordDocument = WordprocessingDocument.Open(docStream, true))
                    {
                        if (wordDocument.WebExTaskpanesPart == null)
                        {
                            wordDocument.AddWebExTaskpanesPart();
                        }

                        CreateWebExTaskpanesPart(wordDocument.WebExTaskpanesPart);
                        docStream.Seek(0, SeekOrigin.Begin);
                    }

                    return docStream.ToArray();
                }
            }

    So please let me know the solution for this issue.

    Tuesday, April 25, 2017 1:31 PM
  • I have tried to reproduce your issue with your current code, but I failed. Your current code is not complete.

    Could you share us a simple project which could reproduce your issue?


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 26, 2017 6:57 AM