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

101
Vistas
How to change page size Margins and document language through Word Api ? is any alternate way to do that?
  1. i tried to find word api for that but i guess that is not available right now so i thought i can do it by modifying the xml but that
    also didn't work, need to change page size margin and document
    language
     await Word.run(async (context) => {
    var paragraphs = context.document.body;

    // Queue a command to load the style property for the top 2 paragraphs.
    paragraphs.load("style")

    // Synchronize the document state by executing the queued commands,
    // and return a promise to indicate task completion.
    return context.sync().then(function () {
      // let replacedXml=""
      // Queue a a set of commands to get the OOXML of the first paragraph.
      var ooxml = paragraphs.getOoxml()

      // Synchronize the document state by executing the queued commands,
      // and return a promise to indicate task completion.
      return context.sync().then(function () {
        // console.log('Paragraph OOXML: ' + ooxml.value);
        console.log(ooxml.value)
        let str=String(ooxml.value)
        let replacedXml =ooxml.value
        // paragraphs.items[0].insertOoxml(replacedXml,Word.InsertLocation.replace)
        // context.document.body.insertOoxml(replacedXml, Word.InsertLocation.replace);
        var range = context.document.getSelection()
        range.insertOoxml(replacedXml,"Replace")
        // console.log(replacedXml)
      });      
    
    });
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

i tried to find word api for that but i guess that is not available right now

The answer is yes. Here is no such api having functionality as your expectation for now and in recent future.

so i thought i can do it by modifying the xml but that also didn't work, need to change page size margin and document

OOxml is a powerful way to change doc file indeed, but it is only applicable for those very experienced, has a bit unsatisfying performance online and may cause some problems hard to interpret. So in most cases, we don't recommend using ooxml to achieve one's goal actually. Btw, we suggest to test above code in word desktop app. Only if insuring the correctness of code could support us to go on investigating.

At last, you can submit your request in https://techcommunity.microsoft.com/t5/microsoft-365-developer-platform/idb-p/Microsoft365DeveloperPlatform if you really want new api.

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