Loading
Word.Tips.Net WordTips (Menu Interface)

Adding Quotes

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.

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 versions: 97 | 2000 | 2002 | 2003 | 2007

Related Tips:

Create and Merge! Using Word's mail merge tool you can quickly and easily combine data from a variety of data sources to create great individualized documents that incorporate your data in ways that you control. WordTips: Mail Merge Magic is an invaluable source for learning how to harness the full power of Word's mail merging capabilities. Check out WordTips: Mail Merge Magic today!

 

Comments for this tip:

Terry    29 Jan 2012, 13:54
Nice macro.
But the closing quotes have a space before them, unless they occur at the end of a sentence.
Can one get rid of this automatically, for instance by searching the resulting string for space quote and removing the space?
Michael Avidan    29 Jan 2012, 07:03
Jessie,

All you need is explained in the following link:

http://www.officeletter.com/favtips/wordmacros.html

Michael Avidan
“Microsoft®” MVP – Excel
ISRAEL
Michael Avidan    29 Jan 2012, 07:00
...and if the proposed Macro will be saved within the NORMAL.DOT(M) Template - it will be available for all(!) documents (New & Old).
Such a Macro deserves a related Keyboard-shortcut and/or an Icon.

Michael Avidan
“Microsoft®” MVP – Excel
ISRAEL
jessie    27 Jan 2012, 22:23
well, that is confusing! how do you make a macro?

Leave your own comment:

*Name:
Email:
  Notify me about new comments for this tip
Hide my email address
*Text:
*What is 2+3? (To prevent automated submissions and spam.)