Skip to content
Utbildning i Office 365

Troubleshooting 102, corrupt word file

Sometimes you solve a problem in a new way, at least for you, and when you tell people about it, you find out that there are things to learn from my process.

Scenario: Word-document is corrupt and will not open online or in the Word-application.

Why this is, no one really knows, but it affected a whole server. These are old files that was moved from on-site storage to SharePoint and had not been used for a while. This happened more than a year ago, but the problem was recently discovered.

TS 102 – Know more than the average Joe.

TS 101 is always to isolate the cause to something tangible to work with.

So, after getting the error messages, testing the files on a different computer with the same error and the classic check for common anomalies, I confirmed that the files where the problem.

Word-files (docx) is a zip-file, the same as modern PowerPoint and Excel files. With this knowledge I decided to check if the files were corrupt in any way.

1.     Rename to zip.

Rename from .docx to .zip and open in Windows Explorer, it failed. This is bad, but I also know that not all systems are alike, and some systems handles abnormalities better.

2.     Install 7-zip to unpack.

7-zip is a free, open-source tool that is to packaging-formats what VLC is to media, it usually opens it, if it’s not corrupt. Success! But the folder structure was not as I expected.

3.     Analyze the differences.

I started by creating a brand-new word file, added one word to it and saved it. Renamed the file to zip and compared the two. There where major differences.

4.     1 + 1 = 1, but it works

Next was to copy the content of the broken file to the new file, thus keeping all the data that existed, but adding what was missing. Save the zip and rename it back to .docx.

5.     Moment of truth

It worked, as clockwork, the file opened as intended both online and, in the app.,

Bonus chapter

If you can be a programmer, be a programmer. There will be tons of work to merge 100’s of documents, this is where scripts are gold!

I know 7zip has a command-line tool named 7z.exe, this tool can be used instead of the graphical interface, which opens a whole new world.

The process is simple.

  1. Have the new empty file as a template.zip file.
  2. Rename the damaged file to zip.
  3. Unpack both to the same directory, to merge them.
  4. Repack and save.

Building this as a function will make it possible to go through each docx-file in a directory and run this function. Thus, uncorrupting the whole file server in one go!

Word of caution:
Do not apply a solution like this to a server/file system without a plan. Have backups, do tests, quality control, risk handling +++

Thanks for reading and I hope you learnt something.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.