microsoft-word-2013-max-element-depth-constraint-violatedYesterday I encountered an error message when I tried to open a Microsoft Word document. In Microsoft Word 2011 for Mac, it said “The Open XML file … cannot be opened because there are problems with the contents or the file name might contain invalid characters (for example, \/).” I got instant panic because this is a very important file that I have been editing in the last few months. Microsoft Word offered to recover the file, and I did. It showed me the document and everything seemed to be ok. I saved the file and tried to reopen it, the same error message happens again.

Yes I have backup, but it doesn’t really help when the backed up file also showed me the same error message. I had to go back to a backup from 3 days ago and redo all my work. Luckly I still have the recovered file of the latest version so I could just do some copy-paste. However, as soon as I finished the copy-paste process and saved the file, reopening the file brought up the same error message.

I spent hours trying to figure out what caused the error message. I opened the file using Microsoft Word 2007 in a Windows machine and there was no error message. However, when I tried to open the file again in Microsoft Word 2011 for Mac (after some light editing in Windows), I got the same error message again.

Next I tried opening the file in another Windows machine using Microsoft Word 2013. This time I got a different error message: “We’re sorry. We can’t open … because we found a problem with its contents. Operation aborted: max-element-depth constraint violated. Location: Part: /word/webSettings.xml

Still and error message, but at least this message from Word 2013 gave me a lot more useful information. So I coped my important file (created a backup) and did an experiment. Here are the steps that finally fixed my file:

1. Create a backup of your file. Make sure the original file is secure somewhere else. Do the experiment using a second copy of the file.

2. Rename the file extension from docx into zip. If the file extension does not appear, go to your Options in Windows Explorer and find the setting to show it. I can’t really write a complete guide on this because there are so many versions of Windows and each one of them has slightly different ways to do this.

3. Open the zip file. I use Winzip, but you can use other tool to open zip file.

4. Find a file named webSettings.xml inside the zip file.

5. Delete the webSettings.xml file.

6. Save the zip file and close it.

7. Rename its extension back to docx.

8. Open the file again in Microsoft Word, do minor editing and save the file again.

9. Done. The file now opens normally in Microsoft Word 2007 (Windows), Microsoft Word 2011 (Mac) and Microsoft Word 2013 (Windows).

That’s it. I hope it helps. I have checked my file and so far I could not find any problem in the repaired file. The contents are complete and they look normal, including all the formatting. As usual, I do NOT take any responsibility for any possible problems (including data loss) as a result of using these steps. Use this guide at your own risk !

I suspect that this error might come from another program named Mendeley. This is a cloud-based program to manage academic papers and my troubled file does use Mendeley plugin for Microsoft Word to manage its references. However, I couldn’t really figure out why and how it happened (the error), and I am happy that I managed to fix my file. So it’s all good for now.