M
mmalinsky
I have the following code that assigns the numpad decimal to a comma.
Most of the code came from another posting in this NG and I added some
code to turn this on/off using a toolbar button using the msoButtonUp
and msoButtonDown properties to indicate if this feature is turned off
or on. The problem I'm running into is that if I have the feature
turned on (msoButtonDown) and close a document, a get a prompt asking
is I want to save the changes to the template. I'm assuming this is
because the original state of the button is up and when I close the
docment the button is down. I thought I could use a BeforeClose event
to eliminate this, but it doesn't seem to work. Any help is
appreciated. The code is below.
Thanks,
Mike.
Private Sub AssignNumpadPeriodToComma()
'Assigns/unassigns numpad decimal to comma
'using a toolbar button. Thanks to a posting
'by Mark Tangard in the Word VBA users group
'http://groups.google.com/group/microsoft.public.word.vba.general/
browse_thread/thread/17a3ede7fe2866b1/1e742ff147e0abf2?
hl=en&lnk=st&q=wdKeyNumericDecimal&rnum=1#1e742ff147e0abf2
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
End Sub
Sub TypeAComma()
Selection.TypeText ","
End Sub
Private Sub DocumentBeforeClose()
ThisDocument.Saved = False
End Sub
Most of the code came from another posting in this NG and I added some
code to turn this on/off using a toolbar button using the msoButtonUp
and msoButtonDown properties to indicate if this feature is turned off
or on. The problem I'm running into is that if I have the feature
turned on (msoButtonDown) and close a document, a get a prompt asking
is I want to save the changes to the template. I'm assuming this is
because the original state of the button is up and when I close the
docment the button is down. I thought I could use a BeforeClose event
to eliminate this, but it doesn't seem to work. Any help is
appreciated. The code is below.
Thanks,
Mike.
Private Sub AssignNumpadPeriodToComma()
'Assigns/unassigns numpad decimal to comma
'using a toolbar button. Thanks to a posting
'by Mark Tangard in the Word VBA users group
'http://groups.google.com/group/microsoft.public.word.vba.general/
browse_thread/thread/17a3ede7fe2866b1/1e742ff147e0abf2?
hl=en&lnk=st&q=wdKeyNumericDecimal&rnum=1#1e742ff147e0abf2
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
End Sub
Sub TypeAComma()
Selection.TypeText ","
End Sub
Private Sub DocumentBeforeClose()
ThisDocument.Saved = False
End Sub