Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

90
Visualizações
getAncestorOrNullObject() function return undefined in Microsoft Office Word Api

I am trying to use getAncestorOrNullObject() function to fetch parent section and parent article of selected paragraph in Word document with Microsoft Office Word Add-in in MS Word 365, The issue I'm facing is even if the paragraph's having ancestor still it's returning undefined or null. Here, I've attached sample code and word document i have used, below. So please verify!

  async getAncestor() {
    Word.run(async (context: any) => {
      let range = context.document.getSelection().paragraphs;
      context.load(range, 'text,items,font');
      await context.sync();
      let getAncestorId = range.items[0]?.listItem.getAncestorOrNullObject();
      context.load(getAncestorId, 'text');
      await context.sync();
      context.load(getAncestorId.contentControls, 'items');
      await context.sync();
    });
  }

Any suggestion and solution would be helpful.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda