|
|
|
|
|
|
Word
|
Add Quotation Marks To Selected Text
|
|
Ease of Use
|
Easy
|
Version tested with
|
2003
|
Submitted by:
|
lucas
|
Description:
|
Add quotation marks to a single word or a selection of text.
|
Discussion:
|
Sometimes we forget our quotation marks as we type. With this macro assigned to a shortcut key combination or a button you can simply select the text and run the macro and the selection is enclosed in quotation marks.
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.
|
Code:
|
instructions for use
|
Place the following code In a standard module:
Option Explicit
Sub addquotes()
Dim r As Range
With ActiveDocument
Set r = Selection.Words(Selection.Words.Count)
If r.Characters(r.Characters.Count) = " " Then
Set r = .Range(Selection.Words(1).Start, _
Selection.Words(Selection.Words.Count).End - 1)
Else
Set r = .Range(Selection.Words(1).Start, r.End)
End If
If Options.AutoFormatAsYouTypeReplaceQuotes Then
r.InsertBefore Chr(147)
r.InsertAfter Chr(148)
Else
r.InsertBefore Chr(34)
r.InsertBefore Chr(34)
End If
End With
r.Select
End Sub
|
How to use:
|
- Open the Visual Basic Editor by going to Tools-Macros-Visual Basic Editor or use Alt-F11
- On the toolbar of the Visual Basic Editor, go to insert - module
- In the module pane paste the code above.
- Close the Visual Basic Editor by clicking the X in the upper right corner or go to File-Close
|
Test the code:
|
- Select some text on your word document.
- On the main menu go to tools-macro-macros.
- In the dialog window select addquotes and then click run.
|
Sample File:
|
put quotes around selection.zip 7.78KB
|
Approved by mdmackillop
|
This entry has been viewed 94 times.
|
|