3

The Context

Currently I am developing a Word add-in that uses the new Javascript API's for Office. The add-in consists of some basic functionalities and a number templates. One of the wishes from the client is to open the templates from the ribbon. Currently I have a command add-in dropdown, where each dropdown menu item refers to a function in the functions file of the add-in. These functions in turn call some Word Javascript API methods, that read and open a base64 string from a .docx file.

The Problem

Simple files are opened without any problems, however more complicated files that contain images, content controls, etc fail. The more complicated files raise a 'GeneralException'. The author of this issue states that it has to do with images that are contained within the document. However this does not align with my personal experience. Images can be added, and the document is still opened. So I assume some other part of the document might trigger problems, however I am not sure!

Therefore I was wondering whether someone is able to shed some more light on this problem.

Code

            Word.run(function(context) {
                let letterTemplate = context.application.createDocument(<base64string>);
                letterTemplate.open();

                return context.sync().then(function () {
                    console.log("success");
                })
                .catch(function (error) {
                    console.log(error);
                })
            });

Any help, tips or advice are welcome.

EDIT: Problem Identified

After some experimentation, I concluded the following. Whenever a (in this case rich text) content control is added to the header in a document, it cannot be opened with the method context.application.createDocument. Trying to do this will result in a 'GeneralException', which does give any specific information. My suspicion is that this is a bug in the Office Javascript API.

1 Answer 1

1

If you are working on word online then please check whether your base64 is large than 4M. Currently base64 larger than 4M will fail with GeneralException. We are working on improve the limitation actively.

Sign up to request clarification or add additional context in comments.

2 Comments

Unfortunately, I am not working with Word Online. However I have found the issue, when a content control is added to the header of a document, this document cannot be opened with the context.application.createDocument method.
We experience it also. The Word version seems to be related. In the Monthly channel, the createDocument method works, but in the Insider versions (1803, 1804) the createDocument method throws an General Exception

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.