I have the following problem... I would like to catch the keypresses while standing in Excel on a sheet, because I would like to use it for setting an autofilter on and searching in a sheet, which I am going to use as a phonebook. I have the following code for starting a timer.

Option Explicit

Private Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimer As Long) As Long

Private Const MY_NID = 88
Private Const MY_ELAPSE = 100
Sub Main()
Dim rVal As Long

rVal = SetTimer(0, MY_NID, MY_ELAPSE, _
AddressOf MyWin_Event)
End Sub

Sub MyWin_Event()
Dim i, KeyResult As Integer
For i = 0 To 255
KeyResult = GetAsyncKeyState(i)
If KeyResult = -32767 Then
If i = 122 Then
MsgBox "F11"
End If
End If
Next i

End Sub

My problem is that GetAsyncKeyState(i) gives me an error and Excel crashes. I hope someone inhere has an idear on howto make my idear work.