Using insertOoxml to insert a MergeField does not work in Word Online

Jordan Trevino 5 Reputation points
2023-10-06T23:01:54.53+00:00

We are using the "insertOoxml" method to insert an XML node that corresponds to a MailMerge MergeField. It works in the Desktop versions of Word, however, in Word Online we get an alert that says "Inserting" and then another that says "Waiting" (image below). After a few seconds the alert disappears but the MergeField does not appear to be inserted. After hitting enter a few times in the word doc the MergeField eventually appears.

Any help or idea on what's going on would be appreciated.

This is the code we are using for inserting the XML node.

insertTextNewApi(xmlNode) {
    Word.run(function (context) {
      var thisDocument = context.document;
      var mergeField = context.document.getSelection().insertOoxml(xmlNode, Word.InsertLocation.replace);
      mergeField.select("End")
      return context.sync().then(function () {
        console.log("Merge field inserted");
      });
    });
  }

And this is what we get. User's image

User's image

User's image

Microsoft Office Online Server
Microsoft Office Online Server
Microsoft on-premises server product that runs Office Online. Previously known as Office Web Apps Server.
599 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,596 questions
0 comments No comments
{count} vote