Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Sub topleft()
Dim hwnd As Long
Dim fnd As Long
Dim AWB As Long
Dim naam As String
fnd = Application.hwnd
Dim myrect As RECT
fnd = FindWindowEx(fnd, 0&, "XLDESK", vbNullString)
hwnd = FindWindowEx(fnd, 0&, vbNullString, vbNullString)
While hwnd <> 0
naam = String$(100, Chr$(0))
rv = GetWindowText(hwnd, naam, 100)
If Left$(naam, rv) = ActiveWorkbook.Name Then
AWB = hwnd
End If
hwnd = FindWindowEx(fnd, hwnd, vbNullString, vbNullString)
Wend
rv = GetWindowRect(AWB, myrect)
Dim def As New UserForm1
def.Left = myrect.Left * 0.75
def.Top = myrect.Top * 0.75
def.Show
End Sub