Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, and 2013. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Automatically Formatting Text within Quotes.

Automatically Formatting Text within Quotes

Written by Allen Wyatt (last updated October 1, 2020)
This tip applies to Word 2007, 2010, and 2013


8

Sandy asked how to find all text between quotation marks and format it to be bold. The solution needs to be able to handle multiple words between the quote marks—entire phrases that need to be bold. This is an interesting question, and there are several ways that it can be approached.

One approach is to use Word's powerful Find and Replace feature to do just what you need. Follow these steps:

  1. Press Ctrl+H. Word displays the Replace tab of the Find and Replace dialog box. (See Figure 1.)
  2. Figure 1. The Replace tab of the Find and Replace dialog box.

  3. In the Find What box, enter the following:
  4.      ["|"]*["|"]
    
  5. This must be entered just as it is, without spaces. The character after the first vertical bar is an opening smart quote, and the one after the second vertical bar is a closing smart quote. The smart quotes are entered in the dialog box by holding down the Alt key and typing 0147 on the keypad for the first one, and then 0148 for the second one.
  6. Move the insertion point to the Replace With box.
  7. Click on Format, then Font. Word displays the Replace Font dialog box. (You may need to click on the More button before you can see the Format button.)
  8. Click on Bold option in the Font Style list.
  9. Click on OK.
  10. Make sure the Use Wildcards check box is selected.
  11. Click on Replace all.

Notice that when Word is done with this search and replace, it will have bolded not only the text within the quotes, but the quotes themselves. If you want to change the quotes back to normal, you can do another wildcard search, this time looking for simply ["|"|"] (step 2, with the last two quotes being opening and closing smart quotes) and replacing it with Not Bold formatting (step 5).

It is interesting to note that you must search for ["|"]*["|"] and not simply for "*". The reason for this is quite simple. If you are getting your documents (the ones you are formatting) from someone else, you don't know right off the bat if they used smart quotes, regular quotes, or a combination of both. By using the brackets surrounding the two types of quotes on both sides of a vertical bar, you are telling Word to match with either type of opening or closing quote. When you have Use Wildcards selected, Word discriminates between regular and smart quotes. (It doesn't discriminate if you are using Search and Replace without wildcards turned on.)

If you need to do quite a bit of formatting of information between quotes in this manner, the best bet is to create a macro that you can assign to a shortcut key or to the Quick Access Toolbar. Perhaps the easiest way is to simply use the macro recorder to record the above steps. If you prefer, you can utilize the following macro to do the trick:

Sub BoldBetweenQuotes()
' base for a quotes finding macro
    Dim blnSearchAgain As Boolean
    ' move to start of doc
    Selection.HomeKey Unit:=wdStory
     ' start of loop
    Do
        ' set up find of first of quote pair
        With Selection.Find
            .ClearFormatting
            .Text = Chr(34)
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindStop
            .Execute
        End With
        If Selection.Find.Found Then
            Selection.MoveRight Unit:=wdCharacter, Count:=1
            ' switch on selection extend mode
            Selection.Extend
            ' find second quote of this pair
            Selection.Find.Execute
            If Selection.Find.Found Then
                Selection.MoveLeft Unit:=wdCharacter, Count:=1
                ' make it bold
                Selection.Font.Bold = True
                Selection.Collapse Direction:=wdCollapseEnd
                Selection.MoveRight Unit:=wdCharacter, Count:=1
                blnSearchAgain = True
            Else
                blnSearchAgain = False
            End If
        Else
            blnSearchAgain = False
        End If
    Loop While blnSearchAgain
End Sub

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 (8436) applies to Microsoft Word 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Word here: Automatically Formatting Text within Quotes.

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

Accessing Paragraphs in a Macro

Need to process a document, paragraph by paragraph, in a macro? It's easy to do once you understand that Word's object ...

Discover More

Updating a Field in a Text Box

If you put a field into a text box, you might be surprised to find that it doesn't update when you try to update all your ...

Discover More

Printing Only Non-Blank Worksheets

If you have a workbook containing many worksheets, you might want to print only those worksheets that have some sort of ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

More WordTips (ribbon)

Smushing Text Together

Word gives you control over how your text appears on the page. This includes adjusting how close letters are to each ...

Discover More

Strikethrough Shortcut Key

One common type of formatting is strikethrough, which is normally applied from the Font dialog box. There is no built-in ...

Discover More

X-ing Out Text

You can easily use strikethrough formatting to show deleted text in a document. What if you want to actually overprint ...

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 1 + 1?

2021-02-24 19:48:32

Siva

In some programming language IDEs (e.g. Pycharm) one can select a word or phrase and press the single or double quote, or any type of bracket, which will enclose the selected text in quotes or brackets. Is it possible with Word?


2017-02-27 13:38:42

lisagd

As a copy editor, I ask all of you not to use quotes to make a word stand out. Use bold, italics, font color, or all caps instead. Quotes serve several specific purposes, and highlighting a word is not one of them.


2016-05-17 16:14:53

Lorraine

How to add underlying to automatically formatting text within quotes?
Thanks.


2015-06-03 07:49:35

Mary

I realized what I had done incorrectly in copying your macro into a "create" a macro and it worked. So now I use Alt I to run it and it works. Thanks. Took a few hours to figure out what I was doing incorrectly, but all is well.


2015-06-02 08:05:06

Ken Endacott

To fix the macro so that it finds all occurrences of quote pairs add the line:
Selection.ExtendMode = False
just before the line:
blnSearchAgain = True

However, the macro will only find straight quotes. The following macro will find both straight and curley quote pairs. Beware, if there is a single quote in the document then it will upset the finding of pairs.

Sub BoldBetweenQuotes()
' quotes finding macro
Dim blnSearchAgain As Boolean
' move to start of doc
Selection.HomeKey unit:=wdStory
' start of loop
Do
With Selection.Find
.ClearFormatting
.Text = "[" & Chr(34) & "|" & Chr(147) & "]*[" & Chr(34) & "|" & Chr(148) & "]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Execute
End With
If Selection.Find.Found Then
Selection.MoveStart unit:=wdCharacter, Count:=1
Selection.MoveEnd unit:=wdCharacter, Count:=-1
Selection.Font.Bold = True
Selection.Collapse Direction:=wdCollapseEnd
Selection.MoveRight unit:=wdCharacter, Count:=1
blnSearchAgain = True
Else
blnSearchAgain = False
End If
Loop While blnSearchAgain
End Sub


2015-06-01 14:50:32

Mary

Hi: I tried to copy your macro you used for the bold text between quotes. I gave it a name, the record button came on I pasted your program macro to it and stopped recording. When I tried to run it, nothing happened. It actually gave me a copy of the macro I copied from your site. I used the Alt O as my keyboard shortcut. I tried copying your code using mouse and did not work, then I used Ctrl A to highlight whole code and paste in macro box and nothing happened. So I am doing something incorrectly. Any help please.


2015-04-14 12:32:24

Lorraine

I tried the macro and it only bolds one word in the document.


2013-09-15 09:31:57

Ferdinand Spek

Hello Alan,

I found your website through a search for my problem. Excellent website by the way!

The problem I am having is that I have a document with lots of text between quotes (signal names actually of varying word lengths) and I want to extract them to a separate document. A colleague of mine made a macro to extract acronyms to a new document, so I was thinking about a combination of this macro and the other.

I tried to combine the macros but can't get it to work. I tried your macro on a separate document, but it seems to make only the first quote bold. Is that correct?

Below my macro so far, any help is appreciated.

Best regards, Ferdinand Spek

Sub ExportBetweenQuotes()
Dim oDoc_Source As Document
Dim oDoc_Target As Document
Dim strListSep As String
Dim strQuote As String
Dim oTable As Table
Dim oRange As Range
Dim n As Long
Dim strAllFound As String

Set oDoc_Source = ActiveDocument
'Create new document for acronyms
Set oDoc_Target = Documents.Add
With oDoc_Target
'Make sure document is empty
.Range = ""
'Insert a table with room for acronym and definition
Set oTable = .Tables.Add(Range:=.Range, NumRows:=2, NumColumns:=2)
With oTable
'Format the table a bit
'Insert headings
.Cell(1, 1).Range.Text = "Quotation"
.Cell(1, 2).Range.Text = "Definition"
'Set row as heading row
.Rows(1).HeadingFormat = True
.Rows(1).Range.Font.Bold = True
.PreferredWidthType = wdPreferredWidthPercent
.Columns(1).PreferredWidth = 50
.Columns(2).PreferredWidth = 50
End With
End With
With oDoc_Source
' base for a quotes finding macro
Dim blnSearchAgain As Boolean
' move to start of doc
Selection.HomeKey Unit:=wdStory
' start of loop
Do
' set up find of first of quote pair
With Selection.Find
.ClearFormatting
.Text = Chr(34)
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Execute
End With
If Selection.Find.Found Then
Selection.MoveRight Unit:=wdCharacter, Count:=1
' switch on selection extend mode
Selection.Extend
' find second quote of this pair
Selection.Find.Execute
If Selection.Find.Found Then
Selection.MoveLeft Unit:=wdCharacter, Count:=1
' make it bold
'Continue while found
strQuote = Selection.Text

'Insert in target doc
'If strQuote is already in strAllFound, do not add again
If InStr(1, strAllFound, "#" & strQuote & "#") = 0 Then
'Add new row in table from second acronym
If n > 1 Then oTable.Rows.Add
'Was not found before
strAllFound = strAllFound & strQuote & "#"
'Insert in column 1 in oTable
'Compensate for heading row
With oTable
'Insert acronym in column 1
.Cell(n + 1, 1).Range.Text = strQuote
'Insert definition in column 2
.Cell(n + 1, 2).Range.Text = "Temp"
End With
n = n + 1
End If

' Selection.Font.Bold = True
Selection.Collapse Direction:=wdCollapseEnd
Selection.MoveRight Unit:=wdCharacter, Count:=1
blnSearchAgain = True
Else
blnSearchAgain = False
End If
Else
blnSearchAgain = False
End If
Loop While blnSearchAgain
'Sort the acronyms alphabetically
With Selection
.Sort ExcludeHeader:=True, FieldNumber:="Column 1", SortFieldType:=wdSortFieldAlphanumeric, SortOrder:=wdSortOrderAscending
.HomeKey (wdStory)
End With
End With

'Clean up
Set oDoc_Source = Nothing
Set oDoc_Target = Nothing
Set oTable = Nothing
MsgBox "Finished extracting " & n - 1 & " quote(s) to a new document."
End Sub


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.