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

95
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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