How to Create a Word VBA Macro to Find the Next Asterisk with F5
Question details
The user needs to create a VBA macro that navigates to the next literal asterisk (*) in the document when the F5 key is pressed.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Navigating quickly through predefined asterisk placeholders in a document using a custom keyboard shortcut.
- Observed behavior
- The user wants to recreate a previously functional macro from Word 97 in Microsoft 365 to map the F5 key to finding the next asterisk.
Ensure that the Developer tab is enabled in your ribbon to access the Visual Basic editor, and save your document as a Macro-Enabled Template (.dotm) if you want the macro available globally.
Create the Find Asterisk Macro and Assign it to F5
Write a specific VBA script using Word's Find object and bind it to the F5 shortcut key.
This solution utilizes Word's built-in Find object. By configuring the macro to search forward and setting MatchWildcards to False, it ensures that Word looks for the literal asterisk character rather than treating it as a wildcard. You can then map this macro to F5 via the keyboard customization settings.
Press Alt + F11 on your keyboard to launch the Visual Basic for Applications (VBA) editor.
In the left-hand Project pane, select 'Normal' to make the macro global. Click 'Insert' from the top menu, then choose 'Module'.
Copy and paste the following code into the blank module window: Sub FindNextAsterisk() With Selection.Find .ClearFormatting .Text = "*" .Forward = True .Wrap = wdFindContinue .MatchWildcards = False If Not .Execute Then MsgBox "No asterisk found." End If End With End Sub
Close the VBA editor. Go to File > Options > Customize Ribbon. Click the 'Customize' button next to 'Keyboard shortcuts' at the bottom.
Scroll down the Categories list and select 'Macros'. On the right, select 'FindNextAsterisk'. Click into the 'Press new shortcut key' box, press the F5 key, click 'Assign', and then close the dialog.

Use WPS Writer for Advanced VBA Macros
WPS Office offers comprehensive support for VBA macros, allowing you to create custom automation scripts like finding asterisks, just as you would in Microsoft Word.
- 1. Enable Developer Tab: Open WPS Writer, navigate to Options, and enable the Developer tab to access all Macro tools.
- 2. Launch the VBA Editor: Click the Developer tab and select 'Visual Basic', or use the standard Alt + F11 shortcut.
- 3. Add Your Code: Insert a new module and paste the Find Asterisk VBA code provided above.
- 4. Run and Customize: Run the macro directly or map it to the F5 key via the customization settings to speed up your workflow.

Frequently Asked Questions
Why does my macro find random words instead of the asterisk?
If MatchWildcards is set to True in your VBA code, the asterisk acts as a wildcard representing any string of characters. You must ensure `.MatchWildcards = False` is explicitly stated in your Find configuration to search for literal asterisks.
How do I save my macro so it works in all future documents?
To make the macro available across all documents, you need to save it in your global Normal template. When opening the VBA editor, ensure you right-click on 'Normal' in the Project pane and insert the module there, rather than in the specific 'Project (Document1)'.
Why doesn't the F5 shortcut work after I assigned it?
By default, F5 is assigned to the 'Go To' dialog box. Make sure that when you assigned F5 to your macro in the Customize Keyboard dialog, you specifically clicked the 'Assign' button before closing. Also, check if any third-party add-ins are overriding the shortcut.




