Cursor Event
Can I trap this event?
Yes. The following code belongs in a standard module.
Run the StartTimer sub to start monitoring.
Run the StopTimer sub to turn turn it off.
Regards,
Vic Eldridge
Declare Function SetTimer Lib "user32" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Declare Function KillTimer Lib "user32" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long) As Long
Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
Type POINTAPI
x As Long
Y As Long
End Type
Dim TimerOn As Boolean
Dim TimerId As Long
Sub StartTimer()
If Not TimerOn Then
TimerId = SetTimer(0, 0, 0.01, AddressOf TimerProc)
TimerOn = True
Else
MsgBox "Timer already On !", vbInformation
End If
End Sub
Sub StopTimer()
If TimerOn Then
KillTimer 0, TimerId
TimerOn = False
Else
MsgBox "Timer already Off", vbInformation
End If
End Sub
Sub TimerProc()
Dim CursorPos As POINTAPI
Dim ThisObject As Object
On Error Resume Next
GetCursorPos CursorPos
Set ThisObject = ActiveWindow.RangeFromPoint(CursorPos.x, CursorPos.Y)
If TypeName(ThisObject) = "Range" Then
If Not ThisObject.Comment Is Nothing Then
StopTimer
MsgBox "Cell " & ThisObject.Address & " has the following
comment," _
& vbCrLf & ThisObject.Comment.Text
StartTimer
End If
End If
End Sub
|