1
votes

When I manually (or via office.js code) insert rows into a table that is in a content control, it increases the number of content controls in the contentControls collection. Word 2016 Windows version 1611.

For example, if I have 1 table in 1 content control, initially the contentControls.items.length = 1. If I insert 3 rows, then the contentControls.items.length = 4.

        Word.run(function (context) {
            var contentCntrls = context.document.contentControls;
            context.load(contentCntrls, "tag");
            return context.sync().then(function () {
                app.showNotification("contentCntrls.items.length: " + contentCntrls.items.length, "");
            });
        })

This produces errors ("Internal Error") in subsequent code that uses the contentControls collection and eventually freezes/crashes Word.

This behavior happens with both the beta and version 1 office.js code. The issue occurs on Windows, but works fine on Macs.

The count of content controls does not change if I check it via VBA: Debug.Print ActiveDocument.ContentControls.Count

If the user saves changes (after inserting rows), then the issue does not occur.

Is this a bug or am I doing something wrong? Is there some workaround (perhaps to reset the CC collection)?

1
In summary: Juan determined that the issue only occurs when saving to OneDrive. Microsoft will work on a fix (perhaps publish in June+). A workaround may be to use the Save API to reset the Content Control collection.Andrew Hall
Andrew, you should not be experiencing this in latest builds (16.0.11128.2000) insiders fast.Juan Balmori

1 Answers

0
votes

UPDATE: The issue is fixed. (REF: 1461591)


Update: we found a bug on this. Happens when the document is stored in OneDrive. we are in the process of fixing it.

--------------LEAVING ORIGINAL ANSWER FOR REFERENCE ---------------------

I was trying to repro this issue, but i am not able to. I tried 2 different paths to test the scenario:

  1. inserted a table, selected the whole table and manually inserted a content control.

  2. inserted a content control, added a few paragraphs then a table inside.

After adding rows to the 1 and 2 tables I did not see the item.length increasing as you describe, it stayed at 1 content control.

Also there is no such thing as build 1611 for Windows. Can you please provide more details on:

  1. how are you inserting the table and the content control
  2. Verify the build number. I tried it in the latest publicly available build which is 16.7766.2068, make sure to update your client before testing.

thanks!