Join
Sign in
Search Options
Search Everything
Search Formats
Home
Blog
Resources
Forums
About Open XML
More ...
Home
»
Forums
»
Formats
»
WordprocessingML
»
EmbeddedObjectPart - cannot open file after it has been embedded
Re: EmbeddedObjectPart - cannot open file after it has been embedded
Formats
Discussions about working with different Open XML Formats
Get this RSS feed
Details
6
Replies
2
Subscribers
Posted
over 2 years ago
Options
Subscribe via RSS
Share this
WordprocessingML
EmbeddedObjectPart - cannot open file after it has been embedded
rated by 0 users
This post has
6 Replies |
2
Followers
Garry
75
Posted by
Garry
on
Tue, Mar 9 2010 7:33 PM
rated by 0 users
Post Points: 20
EmbeddedObjectPart - cannot open file after it has been embedded
Hello,
I have the following code that embeds any file into a DOCX file:
private void AddObjectPart(WordprocessingDocument doc, ExternalContent content) {
EmbeddedObjectPart part = doc.MainDocumentPart.AddNewPart( "application/vnd.openxmlformats-officedocument.oleObject", content.ID );
// Write the content to the part.
using( MemoryStream stream = content.GetContentStream() )
part.FeedData( stream );
}
The following markup is in my DOCX file:
The file is embeded in the document, and it is displaying an image that represents the file.
My problem is, when you double click the image, nothing happens. Word thinks that the image is just an image, and not an OLE object.
I know that the relationships are setup correctly, and I think there is a problem with how I am importing the file.
If I import a TXT file, it doesn't work. But if I import a BIN file, it works. I believe that the OLE object only works a BIN file.
So my question is, how can I convert any file type, so that it will be reconized by the OLE object?
Thanks,
Garry
jlundstocholm
170
Posted by
jlundstocholm
on
Thu, Mar 11 2010 6:34 AM
rated by 0 users
Post Points: 20
Re: EmbeddedObjectPart - cannot open file after it has been embedded
Hi Garry,
Microsoft Office 2007++ wraps all embedded objects in an OLE2-container. I think that could be the cause of your problems - and an explanation of why .BIN-files work.
I do sadly have no idea of how to do the actual wrapping.
Garry
75
Posted by
Garry
on
Thu, Mar 11 2010 7:28 AM
rated by 0 users
Post Points: 50
Re: EmbeddedObjectPart - cannot open file after it has been embedded
Thanks for the reply.
Yes I figured this out after the post... that the embedded files aren't being converted to compound files... and that the OLE object will only work with compound binary files.
I still haven't found a way to convert any file to a compound binary file manually. Anyone know how to do this?
Thanks,
Garry
jlundstocholm
170
Posted by
jlundstocholm
on
Mon, Mar 15 2010 4:23 PM
rated by 0 users
Post Points: 5
Re: EmbeddedObjectPart - cannot open file after it has been embedded
Hi Garry,
As I was browsing through the new content of OpenXML SDK 2.0 that was just released, I stumpled over this article by Zeyad Rajabi - I think it has what you need:
http://blogs.msdn.com/brian_jones/archive/2009/07/21/embedding-any-file-type-like-pdf-in-an-open-xml-file.aspx
Also, for some background of what a compound file is, see
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.ole.interop.istorage%28VS.80%29.aspx
as well as
http://social.msdn.microsoft.com/Forums/en-US/clr/thread/81d2cc00-c88c-45e1-8663-d721cfc400e1
jlundstocholm
170
Posted by
jlundstocholm
on
Mon, Mar 15 2010 4:36 PM
rated by 0 users
Post Points: 5
Re: EmbeddedObjectPart - cannot open file after it has been embedded
And one more: I don't know what your price-limit is, but take a look at
http://www.independentsoft.de/compoundfile/tutorial/createfile.html
.
€199 is quickly spent in hours trying to put a solution together yourself.
jlundstocholm
170
Posted by
jlundstocholm
on
Tue, Mar 16 2010 11:56 AM
rated by 0 users
Post Points: 20
Re: EmbeddedObjectPart - cannot open file after it has been embedded
Sorry to "interupt" again, but I also noticed this tool from the "Binary-2-DOCX"-tool sponsored by Microsoft.
http://b2xtranslator.sourceforge.net/download.html#source
:-)
Garry
75
Posted by
Garry
on
Tue, Mar 16 2010 7:11 PM
rated by 0 users
Post Points: 5
Re: EmbeddedObjectPart - cannot open file after it has been embedded
Thanks for all of the links.
I've already seen the first two, but I haven't checked out "Office Binary Translator". This looks like what I need.
Thanks again for your help.
Page 1 of 1 (7 items)