ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cursor Event (https://www.excelbanter.com/excel-programming/351583-cursor-event.html)

Gary''s Student

Cursor Event
 
When I move my cursor over a cell containing a comment, the comment pops up.

Can I trap this event?
--
Gary's Student

Jim Thomlinson[_5_]

Cursor Event
 
Nope. There is no Mouse Over event in Excel. There is in buttons and such but
not in cells which is what you are looking for.
--
HTH...

Jim Thomlinson


"Gary''s Student" wrote:

When I move my cursor over a cell containing a comment, the comment pops up.

Can I trap this event?
--
Gary's Student


Tom Ogilvy

Cursor Event
 
For built in capabilities of Excel, this is not supported.

--
Regards,
Tom Ogilvy


"Gary''s Student" wrote in message
...
When I move my cursor over a cell containing a comment, the comment pops

up.

Can I trap this event?
--
Gary's Student




Gary''s Student

Cursor Event
 
Thank you for your fast response. This is just another example of knowledge
not bringing happiness.
--
Gary's Student


"Jim Thomlinson" wrote:

Nope. There is no Mouse Over event in Excel. There is in buttons and such but
not in cells which is what you are looking for.
--
HTH...

Jim Thomlinson


"Gary''s Student" wrote:

When I move my cursor over a cell containing a comment, the comment pops up.

Can I trap this event?
--
Gary's Student


Vic Eldridge[_3_]

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




gavins_satori

Cursor Event
 
Vic

Good code but any chance you know how to check for muse over event on a cell
ie: when over a range the cursor changes (similar to what happens on a
browser for a clickable item / hyperlnk) Best if this can be in .net (add-in
or dll)

Any help / guidence appreciated.

Thanks

"Vic Eldridge" wrote:

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




Vic Eldridge[_3_]

Cursor Event
 
Perhaps the following code will shed some light. Unfortunately though, I
don't know of a way to get Excel to show the "hand" cursor.

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 MousePos As POINTAPI
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 TimerProc()
On Error Resume Next
GetCursorPos MousePos
Application.StatusBar = ActiveWindow.RangeFromPoint(MousePos.X,
MousePos.Y).Address
End Sub

Sub StopTimer()
If TimerOn Then
KillTimer 0, TimerId
TimerOn = False
Else
MsgBox "Timer already Off", vbInformation
End If
End Sub



"gavins_satori" wrote:

Vic

Good code but any chance you know how to check for muse over event on a cell
ie: when over a range the cursor changes (similar to what happens on a
browser for a clickable item / hyperlnk) Best if this can be in .net (add-in
or dll)

Any help / guidence appreciated.

Thanks

"Vic Eldridge" wrote:

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





All times are GMT +1. The time now is 06:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com