VBA & Macro Problems

How to Create a Word VBA Macro to Find the Next Asterisk with F5

Bushra ParveenBushra Parveen Oct 21, 2026 872 views

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.

How to Create a Word VBA Macro to Find the Next Asterisk with F5
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to launch the Visual Basic for Applications (VBA) editor.

2
Insert a New Module

In the left-hand Project pane, select 'Normal' to make the macro global. Click 'Insert' from the top menu, then choose 'Module'.

3
Paste the VBA Code

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

4
Access Keyboard Customization

Close the VBA editor. Go to File > Options > Customize Ribbon. Click the 'Customize' button next to 'Keyboard shortcuts' at the bottom.

5
Assign the Macro to F5

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.

Create the Find Asterisk Macro and Assign it to F5
Macro Ready: You can now press F5 anywhere in your document to instantly jump to the next asterisk. If no asterisk exists, a message box will notify you.
VBA Macro Support

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. 1. Enable Developer Tab: Open WPS Writer, navigate to Options, and enable the Developer tab to access all Macro tools.
  2. 2. Launch the VBA Editor: Click the Developer tab and select 'Visual Basic', or use the standard Alt + F11 shortcut.
  3. 3. Add Your Code: Insert a new module and paste the Find Asterisk VBA code provided above.
  4. 4. Run and Customize: Run the macro directly or map it to the F5 key via the customization settings to speed up your workflow.
Fully compatible with Microsoft Office VBA scripts and macro-enabled formats (.docm)Customizable keyboard shortcuts for seamless macro executionLightweight application with high performance and familiar user interface
microsoft office alternative - wps office

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.