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

207
Vistas
Word Addin Javascript cannot read font.color or font.highlightColor after I set it

I have the following code that sets the font.color

Word.run(async (context) => {
      const newRange = await getTextRange(context, locationText, offset, length);
      if (newRange === null) return null;
      suggestedPosition = newRange;
      suggestedPosition.load('font');
      await context.sync();
      suggestedPosition.font.color = 'White';
      suggestedPosition.track();
      await context.sync();
    });

This works and changes the color to white. Then after I reopen the taskpane, I want my script to be able to find if there is any white colored text left over. I do this by searching through text.

Word.run(async function(context) {
      const body = context.document.body.getRange().getTextRanges([' '], true);
      context.load(body, ['text', 'font']);
      await context.sync();
      for (let i = 0; i < body.items.length; i += 1) {
        const word = body.items[i];
        if (word.font.color === 'White') console.log('found word!!!');
      }
    })

What I get back instead is all the colors of the rest of the text (usually #000000) but the color that I changed, I get back ''. What is it that I am doing wrong? I also tried instead of White to use a random color (#123543) but still the same weird issue.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It may be totally besides the point cause I don't know this API but your problem sounds like when we try to access a style that has been modified in javascript with the style property instead of using the getComputedStyle function.

about 4 years ago · Juan Pablo Isaza Denunciar
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