Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

89
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda