Closed hirandesai closed 8 years ago
@hirandesai, How did you get that OOXML?
I followed these steps: I run the code in VS2015 => It opened word document => From Insert Tab => Selected Online Video =>It opened up a Dialog asking for video link => I used one of link from Youtube => Click on Insert.
That added a video inside the document. Now I select the video in document => click on button which is inside my add-in task pane. The code for click event is as below:
Office.context.document.getSelectedDataAsync(Office.CoercionType.Ooxml, function (result)
{
if (result.status === Office.AsyncResultStatus.Succeeded)
{
showNotification('The selected text is:', '"' + result.value + '"');
}
else
{
showNotification('Error:', result.error.message);
}
});
The result object has status of Succeeded and value property contains that ooxml data which I have pasted in question above. I know it's way to much of ooxml code then what is required for embedding video into word document.... But I'm not good at ooxml.
What are the results if you get OOXML without the embedding the video? Do setters work as expected?
No, I tried inserting a part for image, a blank document ooxml and in all those cases it throws same error... Error Code: 2006 and Message: The format of the specified data object is invalid.
I'm not really sure whether I'm doing wrong with ooxml or the API has bug. Can you provide me sample ooxml input which I will test with my code and let you know the result? If you wish, I can share my code on git hub and you can then have look into the code I'm doing.
Here is more updates....
If I write down ooxml in javascript variable,
for ex:
var ooxml="<?xml version=\"1.0\" standalone=\"yes\"?><?mso-application progid=\"Word.Document\"?> ......"
and execute code, it works perfectly fine.
And if I write ooxml code inside textarea as below
<textarea id="xmlcode" style="display:none;"><?xml version="1.0" standalone="yes"?><?mso-application progid="Word.Document"?>.......</textarea>
and read ooxml from that textarea during insertion code, it throws error...
Weird
Nice find. It looks like the difference is the escape characters. It looks like you found the solution to your problem.
In either case of below code OOXML looks like `<?xml version="1.0" standalone="yes" ?> <?mso-application progid="Word.Document"?>