"The file.docx cannot be opened because there are problems with the contents." Location part:/word/document.xml

Manan picture Manan · Sep 26, 2012 · Viewed 11.5k times · Source

Several users have been facing the document corruption issue very repetitively.

We have an application that stores Word documents on server using Webdav. The users who access and edit those documents on server may be on office 2007 and office 2010. Most of the documents are shared and can be hit by office 2007 and office 2010 users for edits.

Number of users are running into document corruption issue with the following error. ==> "The file xxx cannot be opened because" there are problems with the contents" Details: No erorr detail available. Location part: /word/document.xml Line:1 column 0

After formatting the document.xml file for this document I found out that the error points to line => <wp:docPr id="1026" />

The problematic XML node is within the XML node provided below. All the corrupted documents have the same behavior. They all point to same XML tag . If I take out the complete node the document opens up fine.

 <w:drawing>
          <wp:inline distT="0" distB="0" distL="0" distR="0">
            <wp:extent cx="4572638" cy="3429479" />
            <wp:effectExtent l="0" t="0" r="0" b="0" />
            <wp:docPr id="1026" />
            <wp:cNvGraphicFramePr>
              <a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1" />
            </wp:cNvGraphicFramePr>
            <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
              <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
                <pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
                  <pic:nvPicPr>
                    <pic:cNvPr id="0" />
                    <pic:cNvPicPr>
                      <a:picLocks noChangeAspect="1" />
                    </pic:cNvPicPr>
                  </pic:nvPicPr>
                  <pic:blipFill>
                    <a:blip r:embed="rId4" />
                    <a:stretch>
                      <a:fillRect />
                    </a:stretch>
                  </pic:blipFill>
                  <pic:spPr>
                    <a:xfrm>
                      <a:off x="0" y="0" />
                      <a:ext cx="4572638" cy="3429479" />
                    </a:xfrm>
                    <a:prstGeom prst="rect">
                      <a:avLst />
                    </a:prstGeom>
                  </pic:spPr>
                </pic:pic>
              </a:graphicData>
            </a:graphic>
          </wp:inline>
        </w:drawing>

After saving the document on my local machine and open it with open and Repair option the problematic tag looks like this => <wp:docPr id="1026" name="Picture 1026"/> And the complete node looks as given below.

 <w:drawing>
          <wp:inline distT="0" distB="0" distL="0" distR="0">
            <wp:extent cx="4572638" cy="3429479"/>
            <wp:effectExtent l="0" t="0" r="0" b="0"/>
            <wp:docPr id="1026" name="Picture 1026"/>
            <wp:cNvGraphicFramePr>
              <a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/>
            </wp:cNvGraphicFramePr>
            <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
              <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
                <pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
                  <pic:nvPicPr>
                    <pic:cNvPr id="0" name=""/>
                    <pic:cNvPicPr>
                      <a:picLocks noChangeAspect="1"/>
                    </pic:cNvPicPr>
                  </pic:nvPicPr>
                  <pic:blipFill>
                    <a:blip r:embed="rId8"/>
                    <a:stretch>
                      <a:fillRect/>
                    </a:stretch>
                  </pic:blipFill>
                  <pic:spPr>
                    <a:xfrm>
                      <a:off x="0" y="0"/>
                      <a:ext cx="4572638" cy="3429479"/>
                    </a:xfrm>
                    <a:prstGeom prst="rect">
                      <a:avLst/>
                    </a:prstGeom>
                  </pic:spPr>
                </pic:pic>
              </a:graphicData>
            </a:graphic>
          </wp:inline>
        </w:drawing>

Please help me on this one.

Answer

scanny picture scanny · Dec 26, 2013

The short answer is that "name" is a required attribute on both the docPr and cNvPr elements:

<xsd:complexType name="CT_PictureNonVisual">
  <xsd:sequence>
    <xsd:element name="cNvPr"    type="a:CT_NonVisualDrawingProps"/>
    ...
  </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="CT_Inline">
  <xsd:sequence>
    ...
    <xsd:element name="docPr" type="a:CT_NonVisualDrawingProps"/>
    ...
  </xsd:sequence>
  ...
</xsd:complexType>

<xsd:complexType name="CT_NonVisualDrawingProps">
  ...
  <xsd:attribute name="id"   type="ST_DrawingElementId" use="required"/>
  <xsd:attribute name="name" type="xsd:string"          use="required"/>
  ...
</xsd:complexType>

I would have to guess where in the process that attribute is getting left off or removed. But without it the document.xml part is not schema valid, which would explain the repair step being required.