VBA & Macro Problems

How to Automatically Remove Word Document Metadata When Saving via VBA

John WilsonJohn Wilson Oct 26, 2026 869 views

Question details

The user wants to find a way to automatically strip personal information, document properties, and other metadata from a Word document each time it is saved.

How to Automatically Remove Word Document Metadata When Saving via VBA
Product
Word
Device & OS
not provided
Scenario
Preparing documents for external sharing and ensuring all hidden metadata and personal information are scrubbed automatically upon saving.
Observed behavior
The user needs the correct VBA syntax and instructions on where to place the macro so that it triggers automatically depending on the desired scope (single template vs. all documents).
Before you start

Ensure you have the Developer tab enabled in your word processor to access the VBA editor, and save any current work before modifying macro templates.

Solution 1Recommended

Automate Metadata Removal for All Documents

Use a global FileSave macro stored in the Normal.dotm template to automatically remove metadata every time any document is saved.

By naming your macro 'FileSave', you intercept the default save command. When placed in the global Normal.dotm template, this action will apply to all documents you edit on your machine.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Locate Normal.dotm

In the Project Explorer pane on the left, find the project named 'Normal'. Right-click it, select 'Insert', and choose 'Module'.

3
Insert the FileSave Macro

Paste the following code into the module window: Sub FileSave() With ActiveDocument .RemoveDocumentInformation (wdRDIAll) .Save End With End Sub

4
Save and Close

Save the changes in the VBA editor and close the window. The macro will now run automatically whenever you save a document.

Automate Metadata Removal for All Documents
Avoid Macro Conflicts: Ensure you do not have conflicting 'FileSave' macros stored in multiple custom templates, as this can prevent the macro from executing correctly.
Advanced Document Management

Easily Manage Document Properties and Automation in WPS Writer

WPS Office provides highly compatible tools for managing your documents safely. You can easily view or modify document properties, and utilize advanced VBA macro capabilities in the professional versions to automate your document workflows just like Microsoft Word.

  1. 1. Open Your Document: Launch WPS Writer and open the document you wish to scrub or automate.
  2. 2. Access Document Properties: Click the 'Menu' button at the top left, select 'Document Properties', and review your metadata.
  3. 3. Utilize the Developer Tools: Navigate to the 'Developer' tab to access the VBA Editor and seamlessly run your custom macros.
Fully compatible with Microsoft Word .docm macro-enabled formatsIntuitive Document Inspector for managing propertiesLightweight application with robust automated workflow supportCost-effective with a highly familiar user interface
microsoft office alternative - wps office

Frequently Asked Questions

What exactly does wdRDIAll remove from my Word document?

The wdRDIAll constant instructs the macro to strip out all document information. This typically includes author names, custom properties, personal information, comments, and hidden text.

Why isn't my FileSave macro running automatically?

This usually happens if you have multiple loaded templates containing a macro named 'FileSave'. Check your active templates and the Normal.dotm file to ensure there are no conflicting macros.

Can I trigger this macro manually instead of automatically on save?

Yes. If you rename the macro from 'FileSave' to something else (e.g., 'RemoveMetadata'), it will not run automatically. You can then assign it to a keyboard shortcut or a button on your Quick Access Toolbar to run it only when desired.