1
votes

I am trying to open a base64 encoded file in Word Online, using the code below based on .

function displayContents(myBase64) {
    Word.run(function (context) {
        console.log(Office.context.requirements.isSetSupported("WordApi", "1.1"));

        // Create a proxy object for the document.
        var thisDocument = context.document;

        // Queue a command to clear the body contents. 
        thisDocument.body.clear();
        thisDocument.body.insertFileFromBase64(myBase64, "replace");

        // Create a proxy object for the default selection. 
        //var mySelection = thisDocument.getSelection();

        // Queue a command to insert the file into the current document.
        //mySelection.insertFileFromBase64(myBase64, "replace");

        // Synchronize the document state by executing the queued commands, 
        // and return a promise to indicate task completion.
        return context.sync();
    })
    .catch(function (error) {
        console.log('Error: ' + JSON.stringify(error));
        if (error instanceof OfficeExtension.Error) {
            console.log('Debug info: ' + JSON.stringify(error.debugInfo));
        }
    });
}

This does not work (using body.insertFileFromBase64 or myselection.insertFileFromBase64). The code does function in the regular version of Word. I receive the following error:

Error: "name":"OfficeExtension.Error", "code":"GeneralException", "message":"This browser does not support the requested API.", "traceMessages":[],"debugInfo":{}} LoadOfficeDoc.js:51 Debug info: {}

Office.context.requirements.isSetSupported("WordApi", "1.1") returns true.

Am I doing something wrong or is this functionality not available online?

2

2 Answers

3
votes

The new Word API (e.g. anything using Word.run) is presently only supported in Word 2016 on Windows (and iPad?)

Though according to the documentation isSetSupported should be returning false.

0
votes

That's correct, this is actually a bug we are working on right now. That requirement set is not full supported on WAC hence the method must return false.