`context.document.body.insertOoxml` breaks documents, breaks a word

I know this is not a question, but I was posted here by Rick Kirkham from here and apparently asking about SO is the way to download bugs for Microsoft products: -p

When I use insertOoxml

with the "replace" parameter, Word will add additional content to the end. For example, when using the following code in Script Lab with a new document with empty words:

$("#run").click(run);

function run() {
    Word.run(function (context) {
        var ooxml = context.document.body.getOoxml();
        return context.sync().then(function () {
            console.log(ooxml.value.length);
            context.document.body.insertOoxml(ooxml.value, Word.InsertLocation.replace);
            return context.sync();
        });
    });
}

      

Each time you run this code, the document document gets an extra paragraph at the end of the body. It gets crazier when the document ends with a content control: take a new document, insert a new content control. Launching run

will duplicate the content control and insert it inside itself (so you have two content controls where one is contained by the other). Clicking a run

couple of times will create lots of nested content controls and slow Word down to crawl. Inserting a text content control and running "run" twice will crash on the word (looks like a null pointer dereference).

This is not a Script Lab related issue, but using Script Lab is the easiest way to reproduce it.

Word Version: 1703 Build 7967.2139, 2016 MSO (16.0.7927.1020) 32-bit.

Expected Behavior: Word does not crash or inject additional content.

So let's ask this question: How can I use a complete document insertOoxml(ooxml, 'replace')

without breaking my documents?

+3


source to share


1 answer


I have verified with a new assembly that Word is not crashing but an extra blank paragraph is being added. This bug was resolved yesterday and a fix will be available next month. Thank!



+4


source







All Articles