VBA & Macro Problems

How to Run a Word Macro Automatically After Pasting

Tauseeq MagsiTauseeq Magsi Nov 2, 2026 872 views

Question details

The user wants to automatically run a series of formatting procedures via a macro immediately after pasting content (such as Excel data) into a Word document.

How to Run a Word Macro Automatically After Pasting
Product
Word
Device & OS
not provided
Scenario
Pasting external content into Word and needing to apply custom tabs, weekday formats, and highlighting automatically without triggering multiple manual macros.
Observed behavior
Standard Ctrl+V and the Clipboard paste command do not trigger custom macros natively unless the paste action is explicitly intercepted. Behavior also unexpectedly differs depending on whether Backspace or Delete is used prior to pasting.
Before you start

Ensure your document is saved as a Macro-Enabled Document (.docm) and that the Developer tab is enabled in your ribbon so you can access the VBA editor.

Solution 1Recommended

Create a Wrapper Macro to Intercept the Paste Command

By creating a custom macro that executes the paste action and then immediately calls your formatting procedures, you can consolidate the workflow into a single keystroke.

By default, standard paste operations in Word do not trigger custom code. You must write a wrapper macro that manually executes the paste command, followed by your custom formatting calls.

Naming your macro 'EditPaste' will automatically override Word's default paste command, meaning Ctrl+V will run your custom script natively.

1
Open the VBA Editor

Press Alt + F11 to launch the Visual Basic for Applications (VBA) editor in Word.

2
Create the Wrapper Macro

Insert a new module and define a sub procedure named EditPaste. Type 'Selection.Paste' on the first line.

3
Call Your Formatting Procedures

Below the paste command, use the 'Call' statement to trigger your other macros (e.g., 'Call FormatTabs', 'Call HighlightText').

4
Test with Keystrokes

Return to your document and press Ctrl+V to paste content. Verify that both the paste action and the subsequent formatting procedures run successfully.

Create a Wrapper Macro to Intercept the Paste Command
Overriding Default Commands: Using the specific name EditPaste tells Word to replace the system's default paste behavior with your macro, eliminating the need to manually reassign keyboard shortcuts.

Automate Document Workflows with WPS Writer

WPS Office offers robust support for VBA macros, enabling you to seamlessly write, edit, and run custom scripts to automate tasks like pasting and formatting.

  1. 1. Enable Developer Tools: Open WPS Writer and enable the Developer tab from the options menu to access macro functionalities.
  2. 2. Open the VBA Editor: Click the 'Macros' or 'Visual Basic' button in the Developer ribbon to launch the scripting environment.
  3. 3. Write the Wrapper Script: Create a new module and input your custom paste and format VBA code.
  4. 4. Execute the Macro: Assign your new macro to Ctrl+V or a custom toolbar button to run your workflow instantly.
Full compatibility with Microsoft Word macro-enabled documents (.docm)Built-in VBA editor for creating powerful automation scriptsLightweight application that runs custom workflows quickly and efficientlyEasily map custom macros to personalized keyboard shortcuts
microsoft office alternative - wps office

Frequently Asked Questions

Can I intercept the default Ctrl+V command directly in Word?

Yes, you can intercept the default Ctrl+V command by naming your custom macro 'EditPaste'. Word recognizes this specific name and will execute your macro instead of the default system paste command.

Why does my macro behave differently if I use Delete instead of Backspace?

Pressing Delete removes characters ahead of the cursor, while Backspace removes characters behind it. This alters the starting insertion point and the active document selection. If your macro uses the 'Selection' object to apply formatting, the differing cursor placement can cause the macro to apply formatting to the wrong area or fail.

How do I assign my custom macro to a different keyboard shortcut?

Go to File > Options > Customize Ribbon, and click 'Customize' next to Keyboard shortcuts. Select 'Macros' from the Categories list, choose your macro, click inside the 'Press new shortcut key' box, press your desired combination, and click 'Assign'.

What should I do if my called procedures are not executing?

Check that the called macros actually exist and are accessible. They should not be marked as 'Private' if they are stored in a different module. Also, use a simple MsgBox test inside the main macro to verify the initial paste trigger is working.