angularms-wordoffice-jsoffice-addinsword-web-addins

Office js Word - Edit Properties in DocumentCreated Class


I'm currently trying to set or delete properties, after creating a new document in Word:

   Word.run(context => {
                const createdDoc = context.application.createDocument(file);
                context.load(createdDoc.properties.customProperties);
                createdDoc.properties.customProperties.add("Test", 42);

                return context
                  .sync()
                  .then(() => {
                    createdDoc.open();                
                  })
        });

This works fine on desktop. The browser version of office displays the following error:

enter image description here Seems like this operation is not available in the browser version. Did someone might found a work around?


Solution

  • DocumentCreated class is not supported in browser More Info

    From the above docs, you can see that the body of the DocumentCreated belongs to the WordApiHiddenDocument Additional Info

    The WordApiHiddenDocument 1.3 is only supported in the desktop and mac's. Currently Due to the mechanism of the browser, we can't implement the DocumentCreated class. thanks!