Hello Collabora Support Team,
I am currently integrating Collabora Online Development Edition (CODE) into my web application using the WOPI protocol and the iframe postMessage API.
I am able to successfully replace normal text in documents using the following UNO command via postMessage:
iframe.contentWindow.postMessage(
JSON.stringify({ MessageId: “Send_UNO_Command”, Values: {
Command: ‘.uno:ExecuteSearch’,
Args: {
‘SearchItem.SearchString’: { type: ‘string’, value: searchText },
‘SearchItem.ReplaceString’: { type: ‘string’, value: replaceText },
‘SearchItem.Command’: { type: ‘short’, value: 3 },
}
} }),
‘*’
);
However, I have Word documents (.docx) that contain Mail Merge fields (MERGEFIELD). These fields are visible in the Collabora Navigator under “Fields”.
My question is: Is it possible to replace or fill MERGEFIELD values programmatically from JavaScript using the postMessage API? For example, replacing a field named “TestField” with a specific value like “123456” — without opening any dialogs.
I have already tried the following approaches without success:
- .uno:ReplaceAll — does not find MERGEFIELD fields
- .uno:ModifyField — opens a dialog, cannot be used programmatically
- .uno:ExecuteSearch with SearchItem.ValueSearch — no effect on fields
Is there a supported way to do this via postMessage/UNO commands? Or is this a planned feature for a future release?
Thank you very much for your support.
Best regards