Adding quotation marks

Z

Ziaforever

I want to be able to highlight a sentence, click a button or, better yet,
right-click, and the sentence is in quotation marks. I have hundreds of
quotes in my document and I don't want to have to add marks at the beginning
and end of each and every one.
 
K

Klaus Linke

Hi,

You can put the macro below on a toolbar button, or keyboard shortcut, or
context menu:

Dim myRange As Range
Set myRange = Selection.Range.Duplicate
' So you don't need to eliminate the ¶ mark from the selection:
If myRange.Characters.Last.Text = vbCr Then
myRange.MoveEnd Unit:=wdCharacter, Count:=-1
End If
myRange.InsertAfter ChrW(&H201D)
' So the quote matches the formatting of the first character:
myRange.Characters(1).Text = ChrW(&H201C) _
& myRange.Characters(1).Text
' Restore the selection to what it was:
myRange.Select

For help with macros, see
http://www.word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm and the links in
that article.

If the paragraphs that should get quotation marks have anything that
distinguishes them from other paragraphs (tab, indent...), you can also put
all the quotes in with one Find/Replace.

Say, if they are all in the "Dialogue" style:
Check "Match wildcards" in "Edit > Replace",
Choose the "Dialogue" style in "More > Format > Style",
Find what: ([!^13]@)(^13)
Replace with: "\1"\2

Regards,
Klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top