Beta Library: https://appsforoffice.microsoft.com/lib/beta/hosted/office.js
Word 2016 Office insider Fast, Version 1610 (Build 7416.1000)
I've got a Word Document that has a simple Table in it (I'm using generating a table with a few rows and columns every time I test, no existing data), and I'm iterating through the rows attempting to populate the cells with text.
I get this error when I attempt this:
Error: ItemNotFound: ItemNotFound
Debug info: {"errorLocation":"TableRowCollection.getItem"}
My application is the Demo WordWebAddin created by MS visual studio, and my code looks like this:
Word.run(function (context) {
var tables = context.document.body.tables
tables.load({ expand:"rows/cells/items/body/text"})
return context.sync().then(function () {
var rows = tables.items[0].rows
rows.items[1].cells.items[1].body.insertText("ryanasoefijasojef", Word.InsertLocation.replace)
return context.sync();
})
})
.catch(errorHandler);
I have tried a variety of mechanisms for navigating to the cell body - if I use cells.items[0].body.text
I get the cell text body back successfully, so I'm able to use the cells the way I'd expect. But no matter what I do, I get some kind of itemNotFound exception. I've also tried a variety of values (or not values for the insert location parameter including (nothing), references to the InsertLocation objects, and the strings "replace", etc. Definitely a possibility I am using the API incorrectly, but I believe I am using it correctly according to the docs.
edit I would love any kind of confirmation. Either that I am doing it right, or wrong, or that it's not working for you, or something. Any help is appreciated!