Closed dhoelzl closed 7 months ago
Thanks for reaching us. I use the insertOoxml to insert some content in Word Online and it works well. Could you share with me the xml content you inserted so we can try to repro the issue?
Thank you for looking at this!
I can reproduce it by creating a new default document, entering the simple text "TEXT" without any additional formatting, selecting that text and executing the following code:
await Word.run(async (context) => {
var sourceRange = context.document.getSelection();
var contentToCopy = sourceRange.getOoxml();
await context.sync();
console.log(contentToCopy.value);
sourceRange.insertOoxml(contentToCopy.value, 'After');
await context.sync();
});
This code should duplicate the selected "TEXT" in the document.
The following is logged to console (the Ooxml to be inserted):
Office Online Build: 16.0.13925.41019
Browser: Google Chrome 88.0.4324.192 (Official build) (x86_64)
Hi @dhoelzl , I've tried the script in our environment. Unfortunately we still cannot repro the issue. I record a video of my repro steps https://1drv.ms/v/s!AsJHyJBDS6CQi_hHTUwFm3cjmig7jQ?e=Wq3wSN . (The video record with Chrome in Win, I also tried with Chrome in Mac). Could you check if my repro step miss anything?
Could you also provide your session id (in the document, choose File->About) which can repro this issue? We will check if there is error information we can look into. Thanks!
Thank you!
What version of Office do you use?
When running the Script on office.com (16.0.13924.41001) I cannot reproduce the problem, but when running it in our installation environment (16.0.13928.41017) the problem occurs. Could there be other differences beyond that version number?
Session ID: 5ca42178-4ead-407e-b143-537d1b3fd0dd Version: 16.0.13928.41017
At the bottom line, Inner Ring (Fastfood): FF3 is displayed.
My version is 16.0.13928.41017, I'm using OneDrive. Do you mean your Office is installed in your own host?
No, we do not host Office, we use the WOPI discovery URL for testing/developing: https://ffc-onenote.officeapps.live.com/hosting/discovery (as documented here: https://wopi.readthedocs.io/en/latest/build_test_ship/environments.html#discovery-urls)
When
insertOoxml
is called in a task pane in an Office-Add-In in a web browser in Office on the web (e.g. a current version of Google Chrome or Microsoft Edge on office.com), the XML won't be inserted and the following exception is generated, regardles of the input the method was given:Example code (reads the XML of the current selection, prints the XML to console and duplicates it in the document by inserting it at the current selection range):
When exactly the same code is executed in a native Office application (e.g. in a current version of Word 365 for Mac) it works as expected.
The script is included by
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script>
The issue seems to have occured already in the past but does not work at the time writing this issue (2021/02/22):
https://stackoverflow.com/questions/52092107/word-insertooxml-method-returning-error-unknown-for-all-input
Expected Behavior
insertOoxml
works also in the web browserCurrent Behavior
insertOoxml
always causes exception and does not work when executed in a web browser in Office for the webSteps to Reproduce, or Live Example
insertOoxml
with any example XML from https://docs.microsoft.com/en-us/office/dev/add-ins/word/create-better-add-ins-for-word-with-office-open-xmlContext
This issue is very critical as it blocks all features requiring to insert document XML (e.g. document property fields) into the document.
Your Environment