SharePoint + Word + Metadata + Spaces = Death
This morning I received an interesting support ticket. The reported issue was that when clicking a document from SharePoint it would completely freeze the browser and Word. I tried it from my desk and was able to reproduce the issue. It was only occurring with a specific document.
Immediately I thought this form must be corrupted. I saved it to my local desktop and was able to open the file without any issues. Bizarre – I click the File menu (I am running Office 2010 but problem exists on both 2007/2010) and all of a sudden Word froze and I received the “Not Responding” message in the title bar. I finally had to kill the process; tried it again, same issue.
I extracted the contents of the DOCX file and started investigating the content. I noticed that the document had metadata columns from SharePoint with some values in them. One metadata column stood out from the rest because it had about 20 blank spaces at the end of it.
I deleted all the blank spaces, re-compiled the DOCX file, and tested it and the problem was gone.
I thought to myself there had to be something special about this document. So I decided to create a brand new SharePoint library with a couple metadata columns and then created a brand new Word document. When I edited the Word document, I immediately went into the Document Properties panel, keyed in some text, and then added about 20 blank spaces. When I clicked the save button, word hung again with a “Not Responding” message.
Decided to do a few more iterations; I added 1 trailing space, worked fine, 2, worked fine, 3, worked fine. I started to notice that the more spaces I added the slower the “Save” dialog got until I eventually hit about 13 spaces and it no longer returned and Word completely froze.
Under normal circumstances, you should never have this many spaces trailing your metadata but I think this user cut and paste the text from another location and selected too much.
In the past, I have had numerous issues that involved Word freezing when saving or opening but never knew the root cause. We generally fixed it by re-creating the document. I at least now have another location to check before we resort to re-creating a document.
Check it for yourself – you will no doubt have the same issue.