0

In an add-in im working on I've pulled Ooxml from an open document and i want to save that specific Ooxml to a new document.

Ive done the following to create a new document as Juan Balmori says in this SO post. How to open new word docx document in word add in

function onaddOpenDoc() {
        Word.run(function (context) {
          // this getDocumentAsBase64 assumes a valid base64-encoded docx file
            var myNewDoc = context.application.createDocument(getDocumentAsBase64());
            context.load(myNewDoc);

            return context.sync()
                .then(function () {
                    myNewDoc.open();
                    context.sync();
                }).catch(function (myError) {
                    //otherwise we handle the exception here!
                    showNotification("Error", myError.message);
                })

        }).catch(function (myError) { showNotification("Error", myError.message); });
    }

A new file is created and opened, but i cant interact with the new file. I've tried getting the myNewDoc.body and .insertOoxml() , but i get this message in the browser version.

Error The action isn’t supported by Word in a browser. Check the OfficeExtension.Error.debugInfo for more information.

The desktop version just opens a new file and does nothing.

My question boils down to, is there any way for me to interact with the body of a document that was created with context.application.createDocument() ?

Brooski
  • 33
  • 4

1 Answers1

0

It appears the things you're looking for are still in Beta and not publicly released. See the DocumentCreated object in the documentation.

The properties are listed, but when you scroll down you'll see the message

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

It seems it will be in the next API requirement set (currently [ API set: WordApiHiddenDocument 1.4 ])

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43