Do we need to call `load` before reading `ooxml` of an API object?

20 Views Asked by At

The following code produces an error in linting, while still working correctly:

function getSelectionOoxml(): Promise<string> {
  return new Promise((resolve) => {
    return Word.run(async (context) => {
      const ooxml = context.document.getSelection().getOoxml()
      await context.sync()
      resolve(ooxml.value)
    })
  })
}

The error message is:

An explicit load call on 'ooxml' for property 'value' needs to be made before the property can be read

Violated rule in this case is office-addins/load-object-before-read. Do we really need to call load before reading ooxml? If yes, what do I provide as argument? I tried value as suggested, but that doesn't work and instead produces another error saying that there is no value property in this object.

0

There are 0 best solutions below