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

When Replace Doesn't Work

Find and Replace is a great tool, but what are you to do if your find or replace doesn't work as you expect? This tip ...

Discover More

Determining a Worksheet's Number

When you add a new worksheet to a workbook, it receives a meaningful name such as "Sheet4" or "Sheet17." If you want to ...

Discover More

Aligning Text on a Specific Character

Want to use tab stops to align text according to the position of a certain character? It's easy to do if that character ...

Discover More

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!

More WordTips (ribbon)

Initiating a New Search

I do a lot of searching in my documents. Sometimes the searches may not go exactly as I expected. Here are some things I ...

Discover More

Applying a Character Style to Bracketed Text

Word has a powerful Find and Replace capability. It is even more powerful if you turn on its wildcard capability. Here's ...

Discover More

Getting Rid of Hidden Text in Many Files

Hidden text is a great boon if you want to make sure something doesn't show up on the screen or on a printout. If you ...

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 four minus 0?

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.