Keybinding code for double-quote key

M

Mark Tangard

Is there a way to specify the KeyCode constant for the double-quote key? It's
mysteriously missing from the Auto List Members of arguments to FindKeyCode.

I know it's a special key because when smart quotes are enabled it delivers the
appropriate opening or closing mark, but that's exactly what I'm trying to
fiddle with. I want to rebind the quote key to type a "dumb" quote if the
selection is in a certain font and a "smart" (curly) quote in all others.

I see how the smart-quote feature might preclude VBA from exposing this
constant, EXCEPT that the constant for the SINGLE quote key (whose output
adjusts similarly if the smart-quote feature is enabled) *is* there, and can be
manipulated in exactly the way I'm attempting. That is, I can bind wdSingleQuote
to the first macro shown below and get the result I'm after:

Sub PlainSingleQuote()
If Selection.Font.Name = "Tahoma" Then
Options.AutoFormatReplaceQuotes = False
DoEvents
Call PlainSingleQuote2
Else
Selection.TypeText Chr$(146)
End If
End Sub

Sub PlainSingleQuote2()
Selection.TypeText Chr$(39)
Options.AutoFormatReplaceQuotes = True
End Sub

Any clues at all, or suggestions for accomplishing it another way? (other than
running a global-replace macro at the end, which is what I'm doing now? TIA.
 
C

Cindy Meister

Hi Mark

On my keyboard, the quote is type by holding Shift, then pressing the "2"
key. On an American keyboard, I believe it's also a Shift combination. Anway,
this will capture the quote key for me:

Application.KeyBindings.Add wdKeyCategoryMacro, "FormatAllTextBoxes",
BuildKeyCode(wdKeyShift, wdKey2)

-- Cindy
 

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