none
Office.JS “This add-in is no longer available” error when creating a Word Document with context.application.createDocument() RRS feed

  • Question

  • I'm developing an add-in for Microsoft Word 2016 using office js version 16.0.8626.1000 

    https*//appsforoffice.microsoft.com/lib/beta/hosted/office.js (replace * with :)

    I use a web service to retrieve a document in base64 format and then I create a new Word instance with that.

    The problem is that whenever I run the add-in from my server (not from visual studio debugger) it opens the document but the add-in frame displays an error

    First Instance:

    https*//i.stack.imgur.com/jjicn.png (replace * with :)

    Second instance:

    https*//i.stack.imgur.com/0jLJo.png (replace * with :)

    This doesn't happen if I run the add-in from visual studio debugger, it opens the new instance without the frame.

    This is my code:

    Office.initialize = function (reason) {
        // Checks for the DOM to load using the jQuery ready function.
        $(document).ready(function () {
            $('#get').click(function () {
                openWord();
            });
        });
    }

    This how I retrieve the document (without real url):

    function openWord() {
        getDocumentAsBase64(function (data) {
            Word.run(function (context) {
                var myNewDoc = context.application.createDocument(data);
                context.load(myNewDoc);
    
                return context.sync()
                    .then(function () {
                        myNewDoc.open();
                        context.sync();
                    })
                    .catch(function (myError) {
                        //otherwise we handle the exception here!
                        updateStatus(myError.message);
                    })
            }).catch(function (myError) {
                updateStatus(myError.message);
            });
        });
    }
    
    function getDocumentAsBase64(callback) {
        $.ajax({
            url: 'http://myurltomydocument.com/getFile',
            data: "{}",
            dataType: "json",
            type: "POST",
            contentType: "application/json; charset=utf-8",
            success: function (response) {
                callback(response.d);
            },
            error: function (response) {
                updateStatus(response.d);
            }
        });
    }

    This is the manifest (https*//pastebin.com/vP7G8MQz - replace * with :) that I'm currently using if anyone wants to replicate the problem with Office 2016

    Monday, December 18, 2017 12:53 PM

All replies

  • Hi Diego Silvera de Souza,

    I try to find the reason but I did not get any cause for the issue.

    looks like issue is little complex.

    I will try to involve some senior engineer to look in to this issue.

    he will try to provide further suggestions to solve this issue.

    Thanks for your understanding.

    Regards

    Deepak


    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, December 19, 2017 9:30 AM
    Moderator
  • Hi Deepak Saradkumar Panchal,

    thank you for your response.

    Indeed I found myself very confused when this problem appeared.

    I could use some help from any specialist in this kind of technology because in my company we are developing a project with office js.

    If there is any news don't hesitate to comment here.

    Regards

    Diego

    Tuesday, December 19, 2017 12:09 PM

  • Finally I found the solution to this problem.

    1. First I downloaded Office 2016 Administrative Template Files (https*//www.microsoft.com/en-us/download/details.aspx?id=49030 - replace * with :). When you run it, it will extract a bunch of files and folders.
    2. Enter admx folder and copy the whole content to C:\Windows\PolicyDefinitions.
    3. Do a gpupdate /force under CMD (or Powershell) as an administrator.
    4. Run gpedit.msc and find the Administrative Template for Office 2016 then Updates (PC configuration >> Administrative Template >> Microsoft Office 2016 >> Updates >> Update Channel) and set the Update Channel to Montly Channel.

    I'm on Version 1711 (compilation 8730.2127 click and run) and everything is working good now.


    EDIT 9/1/2018:
    The error started showing up again. The only thing I did was attaching the runtime logging to debug my add-in manifest. This is still unsolved.
    Friday, January 5, 2018 4:55 PM
  • Hi Diego

    Try asking this on StackOverflow, where the 'Softies who develop the technology hang out:

    https://stackoverflow.com/questions/tagged/office-js


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    Thursday, January 11, 2018 4:22 PM
    Moderator
  • Hi Cindy!

    My question regard this topic is on Stack Overflow too

    https*//stackoverflow.com/questions/47701089/office-js-this-add-in-is-no-longer-available-error-when-creating-a-word-docume

    Unfortunately I couldn't find a similar case nor a solution (or cause to this behaviour).

    Thanks for the sugestion anyway.

    Regards

    Thursday, January 18, 2018 12:45 PM