Is it possible to search a Word document and return all the tables?

144 views Asked by At

I want to iterate through all the tables in a Word document when a user clicks on a button, and change the style of those tables to a predefined style.

Is this possible?

Word.run(function(context) {
        var body = context.document.body;

        context.load(body, 'table');

        //iterate through tables

        return context.sync();
});
1

There are 1 answers

0
Rick Kirkham On

The array to iterate is

context.document.body.tables.items

But you need to load the tables first and sync before you can loop through the tables.items array. Inside your loop you can set various style* properties, font, etc. For details see Table.