Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Adding Quotes.

Adding Quotes

by Allen Wyatt
(last updated March 7, 2016)

6

Normally, you add quote marks to your text as you type. There may be times, however, when you want to add the quote marks at a later time. For instance, while editing your document you may select some text and then want quote marks added around the selected text. You can accomplish this task with the following macro:

Sub AddQuotes()
    Dim sBegQ As String
    Dim sEndQ As String

    If Options.AutoFormatAsYouTypeReplaceQuotes Then
        sBegQ = Chr(147)
        sEndQ = Chr(148)
    Else
        sBegQ = Chr(34)
        sEndQ = Chr(34)
    End If

    Selection.InsertBefore sBegQ
    Selection.InsertAfter sEndQ
End Sub

The macro determines the proper type of quote marks to use, based on whether you have Word's SmartQuotes turned on or not. The proper quotes are then placed before and after the selection.

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 (9) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Adding 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

Graphics and Line Height

If the inline graphics in your document appear "chopped off," it could be directly related to the formatting within the ...

Discover More

Defining Shortcut Keys for Symbols

Do you need to use symbols frequently in your Excel data? The common way to insert them is by using the Symbol dialog ...

Discover More

Drawing Lines

Excel doesn't limit you to only numbers and text in your worksheets. You can also add different types of shapes. Here's ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More WordTips (menu)

Checking for Matching Parentheses

There are lots of little "gottchas" that can make the difference between a finished document and a polished document. One ...

Discover More

Compound Page Numbering

Simple page numbering is easy to add to your documents. More complex numbering (such as two numbering schemes in the same ...

Discover More

Highlighting Duplicate Words

One way to help improve your writing is to minimize the number of duplicated words you use in your prose. Depending on ...

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}] 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 8 + 2?

2018-11-15 13:17:08

toroc

This is great! I took the liberty of improving the code a bit :)
We tend to just double click a word (in case we want to select just one word), then Word selects trailing space or carriage return character. Here is how to deal with such cases:

Sub AddQuotes()

' Surrounds selected phrase with quotation marks

Dim sBegQ As String
Dim sEndQ As String

' Defines system quotation type
If Options.AutoFormatAsYouTypeReplaceQuotes Then
sBegQ = Chr(147)
sEndQ = Chr(148)
Else
sBegQ = Chr(34)
sEndQ = Chr(34)
End If

With Selection.Range
If Mid(Selection, Len(Selection), 1) = " " Then ' In case space is the last character
.Text = sBegQ & Trim(.Text) & sEndQ & " "
.Select
ElseIf Mid(Selection, Len(Selection), 1) = Chr(13) Then ' In case Carriage Return is the last character
.Text = sBegQ & Left(Selection, Len(Selection) - 1) & sEndQ & Chr(13)
.Select
Else
.Text = sBegQ & .Text & sEndQ
.Select
End If
End With

End Sub


2018-10-07 23:32:47

Phil Reinie

In Word 2011 (Mac OS X) it puts in characters chr(236) and chr(238) when the macro runs. What's with that?
(see Figure 1 below)

Figure 1. text left after macro completes.


2017-11-05 15:19:38

Patricia

Thanks. I'd like to use this code to insert French quotes, « and ».
Could you help?


2017-07-06 05:09:09

Haim

Great add-on! It's a feature I've been wanting for a long time, as I do a lot of copying and pasting of quoted text.


2017-06-10 14:02:56

Clifton

Thanks Allen, As usual you come through with proven effective solutions to make our work day easier every day.


2014-10-21 10:25:05

Robbie

Absolutely Brilliant! A simple and elegant solution to an annoying (albeit rare) problem. Thanks!


This Site

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

Newest Tips
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.