04.02.2026, 14:17
Hallo Forum,
wer seine Userform immer genau an die Stelle einer Excelzelle positionieren möchte, der kann dazu folgenden Code verwenden....
wer seine Userform immer genau an die Stelle einer Excelzelle positionieren möchte, der kann dazu folgenden Code verwenden....
Code:
Private Declare PtrSafe Function FindWindowA Lib "user32" ( _
ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Function SetWindowPos Lib "user32" ( _
ByVal hWnd As LongPtr, ByVal hWndInsertAfter As LongPtr, _
ByVal x As Long, ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Sub UserForm_Activate()
Dim oCell As Range
Set oCell = ActiveSheet.Range("B5")
With ActiveWindow.ActivePane
SetWindowPos FindWindowA("ThunderDFrame", Me.Caption), 0&, _
.PointsToScreenPixelsX(oCell.Left - 5), _
.PointsToScreenPixelsY(oCell.Top - 1), _
0&, 0&, &H1 ' &H1 = SWP_NOSIZE
End With
End Sub
ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Function SetWindowPos Lib "user32" ( _
ByVal hWnd As LongPtr, ByVal hWndInsertAfter As LongPtr, _
ByVal x As Long, ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Sub UserForm_Activate()
Dim oCell As Range
Set oCell = ActiveSheet.Range("B5")
With ActiveWindow.ActivePane
SetWindowPos FindWindowA("ThunderDFrame", Me.Caption), 0&, _
.PointsToScreenPixelsX(oCell.Left - 5), _
.PointsToScreenPixelsY(oCell.Top - 1), _
0&, 0&, &H1 ' &H1 = SWP_NOSIZE
End With
End Sub
_________
viele Grüße
Karl-Heinz
viele Grüße
Karl-Heinz
