Open from MOSS document library fails


  1. Boot Word
  2. Insert plain text content control
  3. Save as "foo.docx" and close Word
  4. Open the CCT
  5. Add a custom xml part
  6. Give the root node some text, "foo"
  7. Bind the content control to the root
  8. Save and close the CCT
  9. Navigate to a MOSS document library
  10. Upload foo.docx
  11. From the library, click to read only open
    Word says there is an error on open
    Expected Results:
    No error
    This only repros using the CCT. Binding a document through the object model does not reproduce this bug. SharePoint must be mangling the xml parts.
Closed May 12, 2007 at 6:20 AM by mrscott


wrote May 12, 2007 at 6:20 AM

Resolved with changeset 22376.

mrscott wrote May 12, 2007 at 6:32 AM

After debugging, I’ve discovered that if your document library requires some meta data to be injected into your document (like say have a barcode policy enforcement), SharePoint will go through all the itemPropsN.xml files in \customXml of the package and rename the itemID’s if it does not fit the default pattern of bracketed guid. For the bug in my case, SharePoint actually renamed a perfectly good itemId and then Word failed to open the document because the referenced ID does not exist (SharePoint invented a new one).

To summarize, here’s SharePoints bug: They decide to rename any ds:itemID in \customXml if the string is not in this format “{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx}”.

It turns out my tool decided not to put those {} chars and that’s what confused SharePoint.

DougHawes wrote Apr 1, 2011 at 12:58 PM

I found that I needed to change the NewGuid() to Upper Case below in order for the document to pass using words validation method. As shown below:
        xp.Id = "{" + Guid.NewGuid().ToString().ToUpper() + "}"; /* Using brackets are required due to SharePoint bug. See http://www.codeplex.com/dbe/WorkItem/View.aspx?WorkItemId=10199 */
Before the change I get the following error:
Error description: The attribute 'http://schemas.openxmlformats.org/officeDocument/2006/customXml:itemID' has invalid value {934ced07-88bf-4c02-980f-71347446b493}'. The Pattern constraint failed. The expected pattern is {[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}}., Content type of part with error application/vnd.openxmlformats-officedocument.customXmlProperties+xml, Location of error /ds:datastoreItem[1]

wrote Feb 21, 2013 at 11:32 PM

wrote May 16, 2013 at 11:02 AM