
UserForm, CommandButton, Accelerator Key
Thanks for the replies. I'll check into the GotFocus command. In your
one message, you say you don't know of a way to trigger the macro when I
press a key while a UserForm is displayed. However, from the beginning,
whenever I pressed one of my accelerator keys, the UserForm disappeared
and macro code ran. It just wasn't the proper code for the assigned
accelerator key. I can't send you the UserForm code without sending you
my normal.dot, but it is just a plain old UserForm with only three
CommandButtons (no OK or Cancel). Here is the code I now use to trigger
what I want.
Private Sub TrackAllOn_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 97 Then 'ASCII 97 = "a"
With activedocument
.TrackRevisions = True
.PrintRevisions = True
.ShowRevisions = True
End With
End If
If KeyAscii = 115 Then 'ASCII 115 = "s"
With activedocument
.TrackRevisions = True
.PrintRevisions = False
.ShowRevisions = False
End With
End If
If KeyAscii = 102 Then 'ASCII 102 = "f"
With activedocument
.TrackRevisions = False
.PrintRevisions = False
.ShowRevisions = False
End With
End If
Unload CtrlOO_Dlg
End Sub
Private Sub TrackAllOn_Click()
With activedocument
.TrackRevisions = True
.PrintRevisions = True
.ShowRevisions = True
End With
Unload CtrlOO_Dlg
End Sub
Private Sub TrackDisplayOff_Click()
With activedocument
.TrackRevisions = True
.PrintRevisions = False
.ShowRevisions = False
End With
Unload CtrlOO_Dlg
End Sub
Private Sub TrackOptionsAllOff_Click()
With activedocument
.TrackRevisions = False
.PrintRevisions = False
.ShowRevisions = False
End With
Unload CtrlOO_Dlg
End Sub
Note the first grouping of code. That actually executes depending upon
the key pressed with the UserForm displayed. Previously, I had three Sub
"KeyPress" groupings before, but only the first ran (i.e., the three
sets of options each had its own Sub "KeyPress", but only the first
ran). I then combined them, figured out the ASCII code for the key being
pressed, and created the IF statements. This works, but I keep thinking
that I'm going about this the wrong way. I thought accelerator keys
triggered the command button. I didn't realize they were only designed
to change focus. Well, anyway, I guess if my way works, I should stick
with it. However, if you have any more elegant ideas, please let me
know.
Thanks.
-Rich.
Quote:
> having your code executed by the GotFocus event for the
> command button?
> Cindy Meister
> INTER-Solutions, Switzerland
> http://homepage.swissonline.ch/cindymeister
> http://go.compuserve.com/MSOfficeForum
> This reply is posted in the Newsgroup; please post any
> follow question or reply in the newsgroup and not by e-mail
> :-)