Why Word Document Inspector Removes Custom XML Markup on Specific Saves
🔍 WiseChecker

Why Word Document Inspector Removes Custom XML Markup on Specific Saves

You open a Word document that contains custom XML markup—data you added through the Custom XML Part feature or via a third-party add-in—only to find that the markup disappears after a specific save operation. This issue typically occurs when you run the Document Inspector or save the file in a format that triggers an automatic inspection. The root cause lies in how Word handles hidden metadata and custom parts during compatibility checks and cleanup routines. This article explains exactly why the Document Inspector removes custom XML markup, which save actions trigger the removal, and how to prevent data loss.

Key Takeaways: Custom XML Markup and Document Inspector Behavior

  • File > Info > Check for Issues > Inspect Document > Custom XML Data: This specific inspection item scans for and removes all custom XML parts, including markup you intentionally added.
  • Save as .docx vs .docm vs .dotx: Saving to a macro-free or template-only format forces Word to strip custom XML parts to maintain format compliance.
  • File > Options > Trust Center > Trust Center Settings > Privacy Options > Remove personal information from file properties on save: Enabling this setting triggers an automatic inspection that deletes custom XML data each time you save.

ADVERTISEMENT

Why Word Targets Custom XML Markup During Document Inspection

The Document Inspector in Word is designed to find and remove hidden or sensitive information before you share a file. Custom XML markup is classified as hidden data because it is stored in the file package as separate XML parts that are not visible in the normal document body. Microsoft considers these parts a privacy risk because they can contain metadata, configuration data, or proprietary information that a recipient should not see.

When you run the Document Inspector and select the Custom XML Data option, Word enumerates all custom XML parts stored in the document package. It deletes every part that is not part of the standard Office Open XML schema. This includes markup added through the Content Control data binding system, custom schemas attached via the XML Mapping Pane, and data injected by add-ins that use the CustomXmlPart class in the Office object model.

The removal is permanent. Word does not move the data to the Recycle Bin or create a backup. After the inspection completes, the custom XML parts are gone from the file package. The only way to recover them is to revert to a previous version of the file that you saved before the inspection.

What Counts as Custom XML Markup

Custom XML markup includes any XML data stored in the document that is not part of the built-in WordprocessingML schema. Examples include:

  • XML parts added through the Custom XML Part feature in earlier versions of Word (2007 and 2010).
  • Data bound to content controls using an XML mapping file.
  • Configuration data inserted by third-party add-ins or enterprise document management systems.
  • Metadata stored in custom XML schemas that are attached to the document.

Specific Save Actions That Trigger Automatic Removal

The Document Inspector does not run automatically every time you save. However, certain save actions and settings cause Word to inspect and remove custom XML markup without any manual action from you.

  1. Saving to a Different File Format
    When you save a document that contains custom XML parts to a format that does not support them, Word strips the parts during the conversion. Formats that do not support custom XML include .doc (Word 97-2003), .dot (template), .rtf, .txt, and .pdf. Even saving to .docx with strict conformance mode selected in the Save As dialog can trigger removal because strict mode enforces a narrower set of allowed parts.
  2. Enabling Privacy Option on Save
    Go to File > Options > Trust Center > Trust Center Settings > Privacy Options. If you check the box labeled Remove personal information from file properties on save, Word runs a silent inspection each time you save. This inspection includes the removal of custom XML data. You can see this setting in the Trust Center. When enabled, Word deletes custom XML parts without asking for confirmation.
  3. Running Document Inspector from the Info Tab
    File > Info > Check for Issues > Inspect Document opens the Document Inspector dialog. By default, the Custom XML Data checkbox is selected. If you click Inspect and then Remove All for any category, Word deletes all custom XML parts. This is a one-time manual action, but many users run it before sharing a file and lose data they intended to keep.
  4. Using Save As with Remove Personal Information
    In the Save As dialog, click Tools (next to the Save button) and select General Options. If you check the box Remove personal information from file properties on save, Word applies the same privacy inspection as the Trust Center setting. Each subsequent save in that session will strip custom XML data.

ADVERTISEMENT

If Word Still Removes Custom XML After You Check Settings

Custom XML Disappears After Saving to SharePoint or OneDrive

When you save a document to SharePoint or OneDrive, the server may apply additional policy-based inspections. If your organization has a data loss prevention policy that scans for custom XML data, the server may remove the parts after the file is uploaded. Check with your IT administrator to see if such policies are active. To test, save a copy of the document to a local folder and verify that the custom XML remains intact.

Custom XML Removed After Running the Accessibility Checker

The Accessibility Checker (Review > Check Accessibility) does not remove custom XML data by itself. However, if you run the Accessibility Checker and then use the Fix All button for certain issues, Word may rewrite the document package. During this rewrite, Word sometimes drops custom XML parts that are not referenced by any content control. Always run the Document Inspector separately after using the Accessibility Checker to confirm your data is still present.

Custom XML Missing After Opening in Word Online

Word Online (the browser version) does not support custom XML parts. When you open a document in Word Online and save it, the server strips all custom XML parts from the file. To preserve the markup, open the document only in the desktop version of Word. If you must edit in Word Online, export a local copy first and reapply the custom XML after editing.

Document Inspector Behavior: Manual vs Automatic Removal

Item Manual Document Inspector Automatic Removal on Save
Trigger File > Info > Check for Issues > Inspect Document Privacy option enabled or format conversion
User prompt Shows results and asks to Remove All No prompt—removal happens silently
Custom XML data affected All custom XML parts All custom XML parts
Recovery method Close without saving or restore backup Restore backup or previous version
Prevention Uncheck Custom XML Data before inspecting Disable privacy option and avoid format conversion

The Document Inspector is a useful tool for removing sensitive metadata, but it treats all custom XML parts as removable items. There is no setting to mark specific parts as keepers. If you need to keep custom XML markup, you must either skip the Custom XML Data inspection category or disable automatic privacy cleaning in the Trust Center.

To prevent accidental removal, always save a backup copy of the document before running the Document Inspector. Use File > Save As and choose a different file name. After the inspection, compare the original and inspected files to confirm what was deleted. If you discover missing custom XML data, close the inspected file without saving and reopen the backup.

ADVERTISEMENT