Use VBA to Replace Word Placeholders with Images
Question details
The user needs a reliable way to automate the insertion of a signature image in place of text placeholders using a VBA macro.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Attempting to use a VBA script to trigger an AutoCorrect replacement that swaps a specific text placeholder with a signature image.
- Observed behavior
- VBA inserts only an asterisk instead of the image. Additionally, using SendKeys to simulate a space or punctuation mark fails to reliably trigger the AutoCorrect image replacement.
Ensure your document is saved as a Macro-Enabled Document or Template (.docm or .dotm) so that your VBA scripts and AutoText entries are properly retained.
Use AutoText and Building Blocks via VBA
Bypass AutoCorrect limitations by storing the signature image as an AutoText entry and inserting it via macro.
Word's AutoCorrect requires a physical keyboard trigger like a space or punctuation mark to activate. Simulating this behavior with VBA (such as using SendKeys) is highly unreliable.
Furthermore, replacing a text range directly with an AutoCorrect entry drops the rich text formatting, leaving only a plain text asterisk. By saving the image as an AutoText (Building Block) entry, you can insert it with perfect formatting directly through your macro.
Insert your desired signature image into the Word document, select it, and create a new AutoText entry named 'jdsigture' (or your preferred identifier).
When saving the AutoText entry, ensure you store it in the attached document template (your specific .dotm file) rather than the global Normal.dotm.
Press ALT + F11 to launch the Visual Basic Editor, insert a new Module, and write a script to define the search range for your placeholder text.
Use the VBA Find method to locate the placeholder. Inside the search loop, use the 'oTemplate.BuildingBlockEntries("jdsigture").Insert Where:=oRng, RichText:=True' command to replace the text with your image.

Automate Document Workflows in WPS Office
WPS Office provides robust support for VBA macros, allowing you to seamlessly automate repetitive tasks like replacing text placeholders with images without the frustration of complex workarounds.
- 1. Enable Developer Tools: Open WPS Writer, navigate to the settings, and enable the Developer tab to gain full access to macro tools.
- 2. Launch the VBA Editor: Click on the Developer tab and select 'Visual Basic' or simply press ALT + F11 to open the built-in VBA editor.
- 3. Run Your Macro: Insert a new module, paste your AutoText replacement script, and run it to easily swap placeholders with your signature images.

Frequently Asked Questions
Why does my VBA macro insert an asterisk instead of the AutoCorrect image?
When VBA accesses an AutoCorrect entry that contains an image, it interprets the formatted value as plain text. This strips the image data and returns its placeholder text representation, which defaults to an asterisk.
Can I use SendKeys to trigger AutoCorrect in Word VBA?
While SendKeys can simulate keystrokes like spaces or punctuation marks, it is notoriously unreliable in Word VBA and often fails to trigger the AutoCorrect event consistently across different systems.
Where should I save my custom AutoText image entries?
It is highly recommended to save your custom AutoText entries (such as signature images) directly into the specific document template (.dotm) you are working with. Saving them in the global Normal.dotm template may prevent the macro from working when the document is shared with others.




