Is there a way to get the table of contents of a Word document including the styles used in an add-in?
I'm able to get the full text of the document (including the headings), using console.log(context.document.body.text)
but it just gives me the entire document as a string, stripping away all styles and formatting. I need to get the heading level of each heading so my add-in can check that whatever document I have open is structured correctly.
Text
always returns only a string - no formatting information. Formatting information is available from aRange
object. You might try working with theParagraphs
collection, which can be interated so that theStyle
format can be queried from each paragraph's range. – Cindy Meister