Quick way to put something in quotes?

R

RockyRoad

Is there a command that will put a quote at the beginning and end of
selected text, rather than having to put the cursor at the beginning and
then at the end and type the quote mark?

Thanks
 
M

matt neuburg

RockyRoad said:
Is there a command that will put a quote at the beginning and end of
selected text, rather than having to put the cursor at the beginning and
then at the end and type the quote mark?

There can be if you write one (a macro). m.
 
J

John McGhie [MVP - Word and Word Macintosh]

No. I wish there was :)

You could make a macro to do it ...

Sub QuoteText()

Dim SelectedText As String

If Len(Selection.Range) > 1 Then
Selection.Text = Chr(147) & Selection.Text & Chr(148)
End If
End Sub


Hope this helps

Is there a command that will put a quote at the beginning and end of
selected text, rather than having to put the cursor at the beginning and
then at the end and type the quote mark?

Thanks

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 4 1209 1410
 
R

RockyRoad

No. I wish there was :)

You could make a macro to do it ...

Sub QuoteText()

Dim SelectedText As String

If Len(Selection.Range) > 1 Then
Selection.Text = Chr(147) & Selection.Text & Chr(148)
End If
End Sub

I hadn't made a macro before but it didn't take long to work out. Thanks.

It works, but are those Chr numbers correct? my quotes appeared as the
letter "i" with an accent above it (using the standard Times font in
English).
 
P

Paul Berkowitz

I hadn't made a macro before but it didn't take long to work out. Thanks.

It works, but are those Chr numbers correct? my quotes appeared as the
letter "i" with an accent above it (using the standard Times font in
English).

If you want straight quotes use Chr(34) for both places.

If you want curly quotes, then the "upper ASCII" (not actually ASCII)
numbers are different on the Mac (MacRoman) than ANSI on Windows.

You want Chr(210) and Chr(211) here.

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
R

RockyRoad

Paul Berkowitz said:
If you want straight quotes use Chr(34) for both places.

If you want curly quotes, then the "upper ASCII" (not actually ASCII)
numbers are different on the Mac (MacRoman) than ANSI on Windows.

You want Chr(210) and Chr(211) here.

Thank you.

one related query, when I double click-drag to select the words to put
quotes around, Word selects the space after the final word, meaning the
final quote is placed after the space:

"testing quote "macro

Is this avoidable or should I single click-drag to make sure I have the
exact selection wanted?
 
D

Daiya Mitchell

one related query, when I double click-drag to select the words to put
quotes around, Word selects the space after the final word, meaning the
final quote is placed after the space:

"testing quote "macro

Is this avoidable or should I single click-drag to make sure I have the
exact selection wanted?

I think that's "smart cut and paste" in action, which is controlled by a
checkbox in Preferences, Edit tab. Probably less trouble to occasionally
single click-drag than to turn it off entirely.
 
J

John McGhie [MVP - Word and Word Macintosh]

Awww... Bugger! I knew I shoulda tested the damn thing in Mac Word.

Here it is again. This one will remove extraneous spaces as well. And yes,
I tested it on the Mac this time... Grrrr.... Unicode should be Unicode
should be Unicode, dammit :)


Sub QuoteText()

Dim SelectedText As String

If Len(Selection.Range) > 1 Then
Selection.Text = Chr(210) & Trim(Selection.Text) & Chr(211)
End If
End Sub




If you want straight quotes use Chr(34) for both places.

If you want curly quotes, then the "upper ASCII" (not actually ASCII)
numbers are different on the Mac (MacRoman) than ANSI on Windows.

You want Chr(210) and Chr(211) here.

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 4 1209 1410
 
R

RockyRoad

Awww... Bugger! I knew I shoulda tested the damn thing in Mac Word.

Here it is again. This one will remove extraneous spaces as well. And yes,
I tested it on the Mac this time... Grrrr.... Unicode should be Unicode
should be Unicode, dammit :)


Sub QuoteText()

Dim SelectedText As String

If Len(Selection.Range) > 1 Then
Selection.Text = Chr(210) & Trim(Selection.Text) & Chr(211)
End If
End Sub

Hey, getting even nicer.

Just one problem though - because it trims the space (and doesn't re-add
it after the quote), you get this

Testing "the quote"macro

(a lack of space after the quote symbol)

Is that fixable?
 
J

JE McGimpsey

RockyRoad said:
Just one problem though - because it trims the space (and doesn't re-add
it after the quote), you get this

Testing "the quote"macro

(a lack of space after the quote symbol)

Is that fixable?

This macro will auto-select either straight or smart quotes (depending
on your Tools/Autocorrect/"AutoFormat as you type" setting), and will
trim left and right spaces from the quoted text, while preserving the
spaces (e.g., if 'the quote ' is selected, the result will be '"the
quote" '). It also will put the right-quote before a paragraph mark if
the paragraph mark is the last character selected:

Public Sub QuoteSelectedText()
Dim sTemp As String
Dim sLQuote As String
Dim sRQuote As String
If Selection.Type = wdSelectionNormal Then
sTemp = Selection.Text
If Options.AutoFormatAsYouTypeReplaceQuotes Then
sLQuote = Chr(210)
sRQuote = Chr(211)
Else
sLQuote = Chr(34)
sRQuote = Chr(34)
End If
If Len(Trim(sTemp)) = 0 Then
sTemp = sLQuote & sTemp & sRQuote
Else
If Left(sTemp, 1) = " " Then
sTemp = Right(Space(Len(sTemp)) & sLQuote & _
LTrim(sTemp), Len(sTemp) + Len(sLQuote))
Else
sTemp = sLQuote & sTemp
End If
If Right(sTemp, 1) = " " Then
sTemp = Left(RTrim(sTemp) & sRQuote & _
Space(Len(sTemp)), Len(sTemp) + Len(sRQuote))
ElseIf Right(sTemp, 1) = vbCr Then
sTemp = Left(sTemp, Len(sTemp) - 1) & _
sRQuote & vbCr
Else
sTemp = sTemp & sRQuote
End If
End If
Selection.Text = sTemp
End If
End Sub
 
J

JE McGimpsey

Daiya Mitchell said:
I think that's "smart cut and paste" in action, which is controlled by a
checkbox in Preferences, Edit tab. Probably less trouble to occasionally
single click-drag than to turn it off entirely.

See my response to the other sub-thread...
 
J

John McGhie [MVP - Word and Word Macintosh]

Sure, anything is fixable if you want to write enough code. See John's code
-- which might be accused, in unkind circles of course, of indulging in a
little "feature creep" :)


Hey, getting even nicer.

Just one problem though - because it trims the space (and doesn't re-add
it after the quote), you get this

Testing "the quote"macro

(a lack of space after the quote symbol)

Is that fixable?

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 4 1209 1410
 
J

JE McGimpsey

Sure, anything is fixable if you want to write enough code. See John's code
-- which might be accused, in unkind circles of course, of indulging in a
little "feature creep" :)

Feedback's always welcome...<vbg>
 
K

Klaus Linke

John McGhie said:
Awww... Bugger! I knew I shoulda tested the damn thing in Mac Word.

Here it is again. This one will remove extraneous spaces as well. And yes,
I tested it on the Mac this time... Grrrr.... Unicode should be Unicode
should be Unicode, dammit :)

<g> ... Unicode *is* Unicode, but Chr() uses the local code page, and Unicode for smart quotes is different than both the codes on the PC and Mac:
Selection.InsertBefore ChrW(&H201C)
Selection.InsertAfter Chr(&H201D)

Regards,
Klaus
 
J

JE McGimpsey

Here it is again. This one will remove extraneous spaces as well. And yes,
I tested it on the Mac this time... Grrrr.... Unicode should be Unicode
should be Unicode, dammit :)

<g> ... Unicode *is* Unicode, but Chr() uses the local code page, and Unicode
for smart quotes is different than both the codes on the PC and Mac:
Selection.InsertBefore ChrW(&H201C)
Selection.InsertAfter Chr(&H201D)[/QUOTE]

Unfortunately, ChrW() is not "officially" supported in MacVBA.

However, in this case it works:

? ChrW(&H210C) = Chr(210)
True

? ChrW(&H210D) = Chr(211)
True
 
K

Klaus Linke

Unfortunately, ChrW() is not "officially" supported in MacVBA.

For another thread, I wrote a macro and checked every single (Unicode version2) character.

ChrW() always inserted the "proper" character even in WordX, AscW() always reported the proper code.
If the character is in the current font, it'll display in Word2004. Maybe the help is formulated so prudently because your fonts may not have some characters (that's a problem in WinWord, too), or they just forgot to update that sentence.

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