ich suche eine Möglichkeit in einer geschützten Tabelle durch z.B. Doppelklick die Position der Maus zu ermitteln.
Koordinaten habe ich schon mehrfach gefunden aber die Zelle (Zeile, Spalte) suche ich schon seit Stunden vergebens.
Ein gefundenes Script ermittelt zwar die Zelle, liegt aber immer 4-5 Zeilen unterhalb der tatsächlichen Position (ermittelt z.B. Zeile 41 wenn ich in 37 klicke)
Hat jemand eine Idee?
Besten Dank im Voraus.
Thomas
Option Explicit
Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetDC Lib "user32" ( _
ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" ( _
ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" ( _
ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Declare Function GetCursorPos Lib "user32" ( _
ByRef lpPoint As POINTAPI) As Long
Function WertUnterDerMaus() As Variant
Dim cursor As POINTAPI
Dim x As Double
Dim y As Double
Dim s As Long
Dim z As Long
Dim dc As Long
Dim dpi As Long
Dim IE As Object
Dim DerText As String
dc = GetDC(0)
dpi = GetDeviceCaps(dc, 88)
ReleaseDC 0, dc
Call GetCursorPos(cursor)
x = cursor.x - ActiveWindow.PointsToScreenPixelsX(0)
While x > 0
s = s + 1
x = x - Cells(1, s).Width * dpi / 72
Wend
y = cursor.y - ActiveWindow.PointsToScreenPixelsY(0)
While y > 0
z = z + 1
y = y - Cells(z, 1).Height * dpi / 72
Wend
WertUnterDerMaus = Cells(z, s).Value
MsgBox WertUnterDerMaus
End Function