VBA & Macro Problems

How to Use VBA to Always Paste Unformatted Text in a Word Template

Khadija KhanKhadija Khan Nov 4, 2026 868 views

Question details

The user needs to force the paste command to always insert unformatted plain text exclusively in documents based on a specific template.

How to Use VBA to Always Paste Unformatted Text in a Word Template
Product
Word
Device & OS
not provided
Scenario
Creating a customized template where formatting consistency is required, meaning any text pasted by users must strip its original formatting.
Observed behavior
Because the application lacks a built-in Document_Selection_Paste event to natively handle this restriction, the default paste behavior brings in unwanted external formatting.
Before you start

Ensure the Developer tab is enabled in your ribbon to access the VBA editor, and save your file as a Macro-Enabled Template (.dotm) to retain the code.

Solution 1Recommended

Intercept the Built-in Paste Command with the EditPaste Macro

Create a macro named EditPaste stored inside your specific template. This intercepts the default paste action and converts it to a plain-text paste.

By naming a macro exactly 'EditPaste', you override the application's built-in paste command. Storing it in a specific template rather than the global Normal.dotm ensures it only affects documents created from that template.

1
Open the VBA Editor

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

2
Insert a New Module

In the Project Explorer panel, locate your specific template file. Right-click it, select 'Insert', and choose 'Module'.

3
Paste the VBA Code

In the code window, enter the following code: Sub EditPaste() Selection.PasteSpecial DataType:=wdPasteText End Sub

4
Save and Test

Save the template as a Macro-Enabled Template (.dotm) and close the editor. Create a new document from this template and test the paste command (Ctrl + V) to verify text is pasted unformatted.

Intercept the Built-in Paste Command with the EditPaste Macro
Macro Targeting: Because the macro is stored in the specific template, standard paste commands in other documents will continue to function normally.
Advanced Document Automation

Streamline Your Workflow with Macros in WPS Writer

WPS Writer provides robust support for VBA macros in its advanced editions, allowing you to seamlessly run customized paste commands like EditPaste. With high compatibility, you can manage and execute your Microsoft Word templates flawlessly.

  1. 1. Download and Install WPS Office: Download the latest version of WPS Office and install it on your device.
  2. 2. Open Your Template: Open your macro-enabled template directly in WPS Writer.
  3. 3. Enable Macros: Navigate to the Developer tab, enable macros, and run or edit your VBA scripts identically to how you would in other major office suites.
Fully compatible with Microsoft Word macro-enabled templates (.dotm)Built-in VBA editor for seamless macro recording and executionLightweight application with fast launch timesFamiliar user interface requiring no steep learning curve
microsoft office alternative - wps office

Frequently Asked Questions

Why is there no Document_Selection_Paste event?

The application's object model does not expose a native event strictly for intercepting a paste action. Intercepting core application commands requires overriding the command by name (like EditPaste) rather than using an event listener.

Will the EditPaste macro affect my other documents?

No, provided you save the macro specifically within your custom template (.dotm). It will only override the paste command for documents that are generated from or currently attached to that specific template.

Can I change the global paste options instead of using VBA?

Yes, you can change the default paste format to 'Keep Text Only' in the application's Advanced Options. However, this global setting will apply to all open documents and all future documents, rather than being restricted to just one template.