How to Automatically Remove Word Document Metadata When Saving via VBA
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.

- 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).
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.
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.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.
In the Project Explorer pane on the left, find the project named 'Normal'. Right-click it, select 'Insert', and choose 'Module'.
Paste the following code into the module window: Sub FileSave() With ActiveDocument .RemoveDocumentInformation (wdRDIAll) .Save End With End Sub
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 a Specific Template
Store the FileSave macro within a specific document template so it only strips metadata from documents based on that specific template.
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. Open Your Document: Launch WPS Writer and open the document you wish to scrub or automate.
- 2. Access Document Properties: Click the 'Menu' button at the top left, select 'Document Properties', and review your metadata.
- 3. Utilize the Developer Tools: Navigate to the 'Developer' tab to access the VBA Editor and seamlessly run your custom macros.

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.




