Range.ExportFragment() writes 0 length file if range is a Shape

J

Ji Zhou

Hello Dave,

As my understanding, this should be by design because Shape is floated on
the document. So it does not have a concept of fixed range. Its Anchor
property just represents a linked anchor within the document. So the Anchor
property only is some kind of a placeholder. That is why it exports a 0
length file via ExportFragment. And that is why Anchor.WordOpenXML is not
valid in our another discussion.

The workaround is same as we discussed before, we can first call
ConvertToInlineShape and then export the inline shape. After that, we call
ConvertToShape to convert it back.

Hope this helps and have a nice day!


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support
 
D

David Thielen

Hi;

Is there any way to save a selection that includes a Shape? the
to/fromInline does not work for this case because we are allowing the
user to select any part of the document and it could have multiple
Shapes and InlineShapes in it.

??? - thanks - dave


Hello Dave,

As my understanding, this should be by design because Shape is floated on
the document. So it does not have a concept of fixed range. Its Anchor
property just represents a linked anchor within the document. So the Anchor
property only is some kind of a placeholder. That is why it exports a 0
length file via ExportFragment. And that is why Anchor.WordOpenXML is not
valid in our another discussion.

The workaround is same as we discussed before, we can first call
ConvertToInlineShape and then export the inline shape. After that, we call
ConvertToShape to convert it back.

Hope this helps and have a nice day!


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
D

David Thielen

Also, I think it's a bug that it writes a zero length DOCX file -
shouldn't it be a valid DOCX with an empty document?

thanks - dave


Hello Dave,

As my understanding, this should be by design because Shape is floated on
the document. So it does not have a concept of fixed range. Its Anchor
property just represents a linked anchor within the document. So the Anchor
property only is some kind of a placeholder. That is why it exports a 0
length file via ExportFragment. And that is why Anchor.WordOpenXML is not
valid in our another discussion.

The workaround is same as we discussed before, we can first call
ConvertToInlineShape and then export the inline shape. After that, we call
ConvertToShape to convert it back.

Hope this helps and have a nice day!


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

Ji Zhou

Hello Dave,

I agree that it would be more consistent if it output a valid docx file with
empty content. But considering that it is by design that an anchor range for
a floating shape cannot be exported as fragment, maybe the product just does
some detection and optimization. So it by pass the progress of generate a
valid document for it.

As to the original question, what about creating a new document and copying
the content into it, then saving the new created document to local disk?


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support
 
D

David Thielen

Ok, will do - thanks - dave

Hello Dave,

I agree that it would be more consistent if it output a valid docx file with
empty content. But considering that it is by design that an anchor range for
a floating shape cannot be exported as fragment, maybe the product just does
some detection and optimization. So it by pass the progress of generate a
valid document for it.

As to the original question, what about creating a new document and copying
the content into it, then saving the new created document to local disk?


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top