Converting Text Inside Double Asterisks to Bold

Written by Allen Wyatt (last updated February 24, 2024)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021


3

David has information that he's imported into Word. The information is plain text, and anything that is supposed to be bold is surrounded by double asterisks, as in **this should be bold**. David wonders if there is an easy way to convert this double-asterisk convention into actual bold text.

This can be accomplished relatively easily using Find and Replace, as long as you do your searching and replacing with the aid of wildcards. Follow these steps:

  1. Press Ctrl+H. Word displays the Replace tab of the Find and Replace dialog box.
  2. Click the More button, if it is available. Word expands the Find and Replace dialog box. (See Figure 1.)
  3. Figure 1. The expanded Find and Replace dialog box.

  4. Make sure the Use Wildcards check box is selected.
  5. Enter the following in the Find What box: \*\*(*)\*\*
  6. Enter the following in the Replace With box: \1
  7. With the insertion point still in the Replace With box, click the Format button and then choose Font. Word displays the Replace Font dialog box. (See Figure 2.)
  8. Figure 2. The Replace Font dialog.

  9. Using the Font Style list, choose Bold.
  10. Click OK to dismiss the Replace Font dialog box. You should notice the phrase Font: Bold appears under the Replace With box.
  11. Click on Replace All.

What happens is that Word finds all instances of text within double asterisks, deletes the asterisks, and formats the text as bold. This is done because of the pattern you entered in the Find What box (step 4). The backslashes just before each asterisk cause Word to treat them as actual characters, not as wildcards—which asterisks normally are. The \1 in the Replace With box (step 5) indicates that you want to replace the matched text with whatever is within the first set of parentheses in the Find What box. That asterisk within the parentheses does not use a backslash, so it is a wildcard that matches any text.

The steps to perform the changes are easy to accomplish, but if you do this type of replacement quite a bit, you should consider using a macro to perform the task. You can do so by using the Macro Recorder while you perform the above steps. The macro will look very similar to this:

Sub BoldDoubleAsterisks
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Bold = True
    With Selection.Find
        .Text = "\*\*(*)\*\*"
        .Replacement.Text = "\1"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Run the macro, and all the double-asterisk enclosed text in the document is affected. You can also assign the macro a shortcut key or add it to the Quick Access Toolbar to make it more accessible.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (11222) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Importing Excel Information Into Chart

Microsoft Graph is great for displaying charts in a document, without the need to actually use Excel. However, your data ...

Discover More

Using Stored Views

After creating different views of your worksheet data, you can display those views by simply selecting which one you want ...

Discover More

Creating Individual PDFs by Worksheet

Want to print your worksheets to their own PDF? This can be quite manually intensive, unless you put the macro in this ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More WordTips (ribbon)

Changing the Position of the Dollar Sign

When you receive documents created by others, it is not unusual that you'll want to edit what they've written. For ...

Discover More

Saving Find and Replace Operations

Want to repeat the same Find and Replace operation over and over again? Here are a couple of ways you can improve your ...

Discover More

Changing European Dates to US Dates

Want to change the order of the day and month in a date? This tip shows you how you can do so using the Find and Replace ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is seven minus 2?

2024-02-24 14:38:27

Tomek

Correction:
rather than deleting the line
    .Wrap = wdFindContinue
you should change it to
     .Wrap = wdFindStop

The reason is that this setting is remembered by Word, hence deleting the line may give unexpected results.


2024-02-24 14:24:08

Tomek

Just a caveat:
You have to make sure that when you start the Search-Replace, the cursor is at the very beginning of the document, or at least not between the two double stars marking the text to be bold. Otherwise the process may convert the text that was not to be bold into bold - opposite to what you want.
The same applies when you run the macro, but you can add the following line of code at the beginning of the macro to start at the beginning of the document:
    Selection.HomeKey Unit:=wdStory

The macro as written in the tip will convert the text between double-asterisk marks into bold in the whole document, even if you start with just a selection of text. This is controlled by the line:
    .Wrap = wdFindContinue
You can delete this line if you want the conversion only to apply to the selected text. The caveat still applies.

I propose a slightly modified macro, which will process the whole document starting at the beginning, if the selection is just the insertion point, otherwise it will only process the selected text. This macro can also be run on a header or footer.
-------------------------------
Sub BoldDoubleAsterisksinSelection()
    If Selection.Type = wdSelectionIP Then Selection.HomeKey Unit:=wdStory

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Bold = True
    With Selection.Find
        .Text = "\*\*(*)\*\*"
        .Replacement.Text = "\1"
        .Forward = True
        .Wrap = wdFindStop
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub


2024-02-24 04:47:59

Leanne Bentley

I’d love more wild card tips. I use this one a lot.


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.