Thursday, August 05, 2010

Opening a Word document from SharePoint hangs the browser

Here’s an issue that I ran into on a recent project – when I tried to open a document (for editing) from the SharePoint web site, the browser would hang, Word wouldn’t launch and I would have to end up killing the Word and Internet Explorer processes using the Task Manager.

To keep a long, tedious story short, I eventually discovered that the document’s metadata in SharePoint had trailing spaces. Once I removed these, the document opened up just fine. One or two trailing spaces seemed to be fine, but if there was a lot of them, then it caused issues when trying to open the document in Word.

It’s not particularly easy to get trailing spaces into a document’s metadata. If you try to insert them via the browser user interface, SharePoint automatically removes them for you. However, in this project, I was populating the metadata using code. So now I know to use a Trim statement in my code to remove any trailing spaces when updating a SharePoint document’s metadata.