O
Ogier
Hello out there! I've got 2½ questions:
FIRST QUESTION:
In some documents I use Greek letters and special symbols a lot. I have
therefore used the (I beleive quite standard) code shown below to insert
UNIcode characters with simple keyboard commands, like Alt-G to give a gamma
and Shift-Alt-G to produce a capital gamma:
Public Sub AssignAltKeyToMacro(MacroName As String, Key As WdKey)
KeyBindings.Add KeyCategory:=wdKeyCategoryMacro, _
Command:=MacroName, KeyCode:=BuildKeyCode(wdKeyAlt, Key)
End Sub
(similar sub for ShiftAlt)
Public Sub RemoveAssignmentFromAltKey(Key)
CustomizationContext = NormalTemplate
FindKey(BuildKeyCode(wdKeyAlt, Key)).Clear
End Sub
Public Sub TypeGammaS() ' Gamma
Selection.TypeText ChrW("&H03B3") ' UNIcode hex value
End Sub
Public Sub TypeGammaC() ' Capital Gamma
Selection.TypeText ChrW("&H0393")
End Sub
Public Sub AssignGreekLetters()
CustomizationContext = NormalTemplate
...
AssignAltKeyToMacro "TypeGammaS", wdKeyG
...
AssignShiftAltKeyToMacro "TypeGammaC", wdKeyG
...
End Sub
Public Sub RemoveGreekLetters()
...
RemoveAssignmentFromAltKey wdKeyG
...
RemoveAssignmentFromShiftAltKey wdKeyG
...
End Sub
This works just fine, but is a little lengthy with ~60 Greek letters and
other symbols. Is it possible to avoid the use of the name of the subroutine
and have something like
public Sub AssignCodeToAltKey(UNIcode As String, Key As WdKey)
???
End Sub
with usage
AssignCodeToAltKey "&H03B3", wdKeyG
AssignCodeToShiftAltKey "&H0393", wdKeyG
SECOND QUESTION:
It is fairly obvious that the constant wdKeyG refers to the "G"-key of the
keyboard. But I cannot figure out which keys some other wdKeys refer to on a
non-US keyboard (mine is a Danish one).
In particular I would like to assign commands to the "½" key residing to the
left of "1" and the "<" key to the left of "Z". A US keybord has the
BackSingleQuote character left of "1", but using wdKeyBackSingleQuote has no
effect. And a US keybord has no corresponding key to the left of "Z", the "<"
key residing to the right of "M"!
Is it possible to find out which keys on a non-US keybord are connected with
which of the wdKey constants (in particular wdKeyBackSingleQuote,
wdKeyBackSlash, wdKeyOpenSquareBrace, wdKeyCloseSquareBrace, wdKeySemiColon,
wdKeySingleQuote)?
CURIOSITY QUESTION:
On a French AZERTY-keyboard, does wdKeyQ refer to "A" or "Q"?
A German keyboard has the "Y" and "Z" keys swapped. Then what about wdKeyY
and wdKeyZ?
Best wishes
Holger Nielsen
FIRST QUESTION:
In some documents I use Greek letters and special symbols a lot. I have
therefore used the (I beleive quite standard) code shown below to insert
UNIcode characters with simple keyboard commands, like Alt-G to give a gamma
and Shift-Alt-G to produce a capital gamma:
Public Sub AssignAltKeyToMacro(MacroName As String, Key As WdKey)
KeyBindings.Add KeyCategory:=wdKeyCategoryMacro, _
Command:=MacroName, KeyCode:=BuildKeyCode(wdKeyAlt, Key)
End Sub
(similar sub for ShiftAlt)
Public Sub RemoveAssignmentFromAltKey(Key)
CustomizationContext = NormalTemplate
FindKey(BuildKeyCode(wdKeyAlt, Key)).Clear
End Sub
Public Sub TypeGammaS() ' Gamma
Selection.TypeText ChrW("&H03B3") ' UNIcode hex value
End Sub
Public Sub TypeGammaC() ' Capital Gamma
Selection.TypeText ChrW("&H0393")
End Sub
Public Sub AssignGreekLetters()
CustomizationContext = NormalTemplate
...
AssignAltKeyToMacro "TypeGammaS", wdKeyG
...
AssignShiftAltKeyToMacro "TypeGammaC", wdKeyG
...
End Sub
Public Sub RemoveGreekLetters()
...
RemoveAssignmentFromAltKey wdKeyG
...
RemoveAssignmentFromShiftAltKey wdKeyG
...
End Sub
This works just fine, but is a little lengthy with ~60 Greek letters and
other symbols. Is it possible to avoid the use of the name of the subroutine
and have something like
public Sub AssignCodeToAltKey(UNIcode As String, Key As WdKey)
???
End Sub
with usage
AssignCodeToAltKey "&H03B3", wdKeyG
AssignCodeToShiftAltKey "&H0393", wdKeyG
SECOND QUESTION:
It is fairly obvious that the constant wdKeyG refers to the "G"-key of the
keyboard. But I cannot figure out which keys some other wdKeys refer to on a
non-US keyboard (mine is a Danish one).
In particular I would like to assign commands to the "½" key residing to the
left of "1" and the "<" key to the left of "Z". A US keybord has the
BackSingleQuote character left of "1", but using wdKeyBackSingleQuote has no
effect. And a US keybord has no corresponding key to the left of "Z", the "<"
key residing to the right of "M"!
Is it possible to find out which keys on a non-US keybord are connected with
which of the wdKey constants (in particular wdKeyBackSingleQuote,
wdKeyBackSlash, wdKeyOpenSquareBrace, wdKeyCloseSquareBrace, wdKeySemiColon,
wdKeySingleQuote)?
CURIOSITY QUESTION:
On a French AZERTY-keyboard, does wdKeyQ refer to "A" or "Q"?
A German keyboard has the "Y" and "Z" keys swapped. Then what about wdKeyY
and wdKeyZ?
Best wishes
Holger Nielsen