Hello Dave,
Good morning! This is Ji Zhou [MSFT] and I will be working on this issue
with you.
Firstly I want to ensure I understand this issue correctly. We are trying
to insert a custom data file into the Office Open XML file docx/pptx/xlsx.
But after we save the Office Open XML file, the custom data file we
inserted is lost. Please correct me if my understanding is not accurate.
Based on my research on this issue, before we can add the custom data file
into Office Open XML file, we need to declare the file's extension in the
[Content_Types].xml file. For example, if we want to add a .txt file in the
DOCX file. We need to insert the following line into the
[Content_Types].xml file:
<Default Extension="txt" ContentType="text/plain" />
The reason is that no matter in which folder we put our custom data file,
if Word cannot recognize the file, it will consider the document is
corrupted and delete that custom data file during the recovering process.
And Word recognizes the file type by reading the content of
[Content_Types].xml file. By default, its content looks like:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Types
xmlns="
http://schemas.openxmlformats.org/package/2006/content-types">
<Default Extension="rels"
ContentType="application/vnd.openxmlformats-package.relationships+xml" />
<Default Extension="xml" ContentType="application/xml" />
<Override PartName="/word/document.xml"
ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.
document.main+xml" />
<Override PartName="/word/styles.xml"
ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.
styles+xml" />
<Override PartName="/docProps/app.xml"
ContentType="application/vnd.openxmlformats-officedocument.extended-properti
es+xml" />
<Override PartName="/word/settings.xml"
ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.
settings+xml" />
<Override PartName="/word/theme/theme1.xml"
ContentType="application/vnd.openxmlformats-officedocument.theme+xml" />
<Override PartName="/word/fontTable.xml"
ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.
fontTable+xml" />
<Override PartName="/word/webSettings.xml"
ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.
webSettings+xml" />
<Override PartName="/docProps/core.xml"
ContentType="application/vnd.openxmlformats-package.core-properties+xml" />
</Types>
Without modifying the [Content_Types].xml, if I add a .txt file into the
Word subfolder and open the document, I receive the error says that "The
Office Open XML file test.docx cannot be opened because there are problems
with the contents". After I recovery the document and save it. My added
.txt file is discarded by Word. But, if I add the above line, the .txt file
I added will not be discarded any more.
Hope this helps! If you have any future concerns about this, please let me
know. I will do my best to have some more researches.
Best regards,
Ji Zhou (
[email protected], remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.