M
mmalinsky
I have the following code in an add-in. I've been having problems
with the key binding so I added an autoexec routine which I thought
would clear out the binding value when the add-in was loaded, but that
does not appear to be the case. I tested this by trying to get a
msgbox to pop-up when the add-in was loaded when Word was loaded and
nothing happened. Is there any way to get this to work?
Thanks,
Mike
Option Explicit
Sub AutoExec()
FindKey(BuildKeyCode(wdKeyNumericDecimal)).Clear
MsgBox FindKey(BuildKeyCode(wdKeyNumericDecimal)).KeyCategory
End Sub
Private Sub AssignNumpadPeriodToComma()
Dim SavedState As Boolean
SavedState = ThisDocument.Saved
If FindKey(BuildKeyCode(wdKeyNumericDecimal)).KeyCategory = -1
Then
CustomizationContext = NormalTemplate
KeyBindings.Add KeyCategory:=wdKeyCategoryMacro, _
KeyCode:=BuildKeyCode(wdKeyNumericDecimal), _
Command:="TypeAComma"
CommandBars("Helpers").Controls(1).State = msoButtonDown
Else
If FindKey(BuildKeyCode(wdKeyNumericDecimal)).KeyCategory = 2
Then
FindKey(BuildKeyCode(wdKeyNumericDecimal)).Clear
CommandBars("Helpers").Controls(1).State = msoButtonUp
End If
End If
StatusBar = FindKey(BuildKeyCode(wdKeyNumericDecimal)).KeyCategory
ThisDocument.Saved = SavedState
End Sub
Sub TypeAComma()
Selection.TypeText ","
End Sub
with the key binding so I added an autoexec routine which I thought
would clear out the binding value when the add-in was loaded, but that
does not appear to be the case. I tested this by trying to get a
msgbox to pop-up when the add-in was loaded when Word was loaded and
nothing happened. Is there any way to get this to work?
Thanks,
Mike
Option Explicit
Sub AutoExec()
FindKey(BuildKeyCode(wdKeyNumericDecimal)).Clear
MsgBox FindKey(BuildKeyCode(wdKeyNumericDecimal)).KeyCategory
End Sub
Private Sub AssignNumpadPeriodToComma()
Dim SavedState As Boolean
SavedState = ThisDocument.Saved
If FindKey(BuildKeyCode(wdKeyNumericDecimal)).KeyCategory = -1
Then
CustomizationContext = NormalTemplate
KeyBindings.Add KeyCategory:=wdKeyCategoryMacro, _
KeyCode:=BuildKeyCode(wdKeyNumericDecimal), _
Command:="TypeAComma"
CommandBars("Helpers").Controls(1).State = msoButtonDown
Else
If FindKey(BuildKeyCode(wdKeyNumericDecimal)).KeyCategory = 2
Then
FindKey(BuildKeyCode(wdKeyNumericDecimal)).Clear
CommandBars("Helpers").Controls(1).State = msoButtonUp
End If
End If
StatusBar = FindKey(BuildKeyCode(wdKeyNumericDecimal)).KeyCategory
ThisDocument.Saved = SavedState
End Sub
Sub TypeAComma()
Selection.TypeText ","
End Sub