Share via

Corrupted Word Documents caused by Malformed OpenXml when saving

Anonymous
2022-06-22T14:07:31+00:00

I have discovered an issue when saving a document that causes the document to become corrupt, which means it can no longer be opened.

This issue occurs in the latest version of Word (at the time of writing) in the Current Channel of Office 365.

The version number is 15225.20288 as can be seen below.

I have also reported this issue via Help > Feedback > I don't like something, and linked to this post so they can see screenshots and reproduction steps.

Overview

This seems like an error which has been experienced in past versions of Word but I can now recreate it consistently with the above version.

The actual error that occurs is best described in this post here:

https://answers.microsoft.com/en-us/msoffice/forum/all/error-the-name-in-the-end-tag-of-the-element-must/864fa11e-05f5-47ce-888c-253dada13e32

When saving the document it seems that word is creating malformed xml which causes the document to become corrupted.

Specifically here:

Other examples of this (or a similar issue) on this forum

https://answers.microsoft.com/en-us/msoffice/forum/all/the-name-in-the-end-tag-of-the-element-must-match/eb3e7989-397f-43a7-8f46-b1294ad18e2b

https://answers.microsoft.com/en-us/msoffice/forum/all/end-tag-error-in-word-document/4b594d00-b9a0-47cc-8d0e-d664c881b6c4

And an article for an older version of word

https://docs.microsoft.com/en-GB/office/troubleshoot/word/end-tag-error-when-open-docx

The above fix still works, but then the issue re-occurs when saving the document again.

Reproduction Steps

In order to test this issue I have created a sample document called Corruption Test.docx which can be found here:

https://www.dropbox.com/sh/l2kv7xvpybasjv1/AADIJ5XvuHZLWVz2MSow9FeMa?dl=0

This document is a standard blank word document to which I added 2 textboxes with the exact same anchor point, and then added a content control to one of the textboxes.

In the same folder is also a file called Corruption Test - Broken.docx which is an example of what happens to the document when the corruption occurs.

  1. Open Corruption Test.docx in Word.
  2. Put the cursor after the word TEXT here:

  1. Type some text
  2. Save the document (Ctrl+S or Ribbon Button)
  3. Delete the text you typed
  4. Save the document (Ctrl+S or Ribbon Button)
  5. Close the document
  6. Open the document
  7. The following error will be displayed

Please note that this error does not always occur the first time the above steps are followed, some times it is necessary to repeat the above steps until the issue occurs. The most it has taken me to get it to occur is 6 times.

This issue seems to be caused by the combination of 2 textboxes which share an anchor, and one of them having a content control in them. If I remove either of the textboxes, or the content control I cannot get the issue to occur.

Microsoft 365 and Office | Word | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

6 answers

Sort by: Most helpful
  1. John Korchok 232.4K Reputation points Volunteer Moderator
    2022-06-23T15:15:00+00:00

    You can report this to Microsoft. In Word. click on File>Feedback>Send a Frown. Describe the issue and how you solve it. Submitting sends the report to the Word programming team. They are unlikely to reply.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2022-06-23T08:08:37+00:00

    Yeah, I'd agree, in creating the above document (which I created solely to reproduce this issue) it did seem to only occur when two shapes have the same anchor point. Moving either of the shapes' anchor point resolves the issue and the corruption does not occur.

    The main point of this post is to help identify the actual issue in the software, not attempt to implement a workaround in the document. There is clearly still a bug in the software, and it'd be good if it could be fixed so issues like this don't occur in the future.

    Was this answer helpful?

    0 comments No comments
  3. John Korchok 232.4K Reputation points Volunteer Moderator
    2022-06-22T16:40:01+00:00

    One theory about what cause this bug is when multiple shapes or objects are anchored to the same paragraph in a document. So you can open the source file, then choose File>Options>Display>Object Anchors to display the anchors. Click each shape, then move it's anchor to a different paragraph. The shapes will probably move when you do this. Let us know if that solves the problem or not.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2022-06-22T15:44:38+00:00

    Hi,

    Thanks very much for the offer, but I've managed to fix our internal documents myself. The problem is that the issue keeps coming back until you remove the actual combination of shapes that causes the problem. I was hoping that, as I've been able to recreate the issue consistently, it would aid in actually rectifying the issue rather than just working around it.

    Was this answer helpful?

    0 comments No comments
  5. John Korchok 232.4K Reputation points Volunteer Moderator
    2022-06-22T15:29:47+00:00

    This problem was much more common with Word 2010, but has since mostly disappeared. It's usually possible to repair these documents. Here's my article on the subject: OOXML Hacking: Document Repair If you can upload one to a cloud service, then post a share link here, I'll take a look at it.

    Was this answer helpful?

    0 comments No comments