Sorry, there is my code:
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
Public Function centerFormOnAppWindow(frmIn As Object) As Long
Dim w As Long, h As Long
Dim frmLeft As Long, frmTop As Long
Dim frmWidth As Long, frmHeight As Long
Dim frmX As Long, frmY As Long
Dim leftNew As Long, topNew As Long
Dim AppW As Long, AppH As Long
Dim AppCenterX As Long, AppCenterY As Long
Dim dx As Long, dy As Long
Dim dblCfnt As Double
Dim lpRectApp As RECT, lpRectFrm As RECT
Dim res As Long
Dim frm As Form
centerFormOnAppWindow = 0
res = 0
Set frm = Nothing
On Error Resume Next
Set frm = frmIn
If frm Is Nothing Then Set frm = frmIn.Parent
On Error GoTo 0
If frm Is Nothing Then Exit Function
If Not frm.Moveable Then Exit Function
' Access Application window parametrs
res = GetWindowRect(Application.hWndAccessApp, lpRectApp)
If res <> 0 Then
With lpRectApp
AppW = .Right - .Left
AppH = .Bottom - .Top
End With
AppCenterX = AppW / 2
AppCenterY = AppH / 2
frmHeight = frm.WindowHeight
frmWidth = frm.WindowWidth
frmLeft = frm.WindowLeft
frmTop = frm.WindowTop
' Form window parametrs
res = GetWindowRect(frm.hwnd, lpRectFrm)
If res <> 0 Then
dblCfnt = frmWidth / (lpRectFrm.Right - lpRectFrm.Left) '
coefficient from system units (pixels?) to form units (twips?)
AppCenterX = AppCenterX * dblCfnt
AppCenterY = AppCenterY * dblCfnt
frmX = frmWidth / 2 + frmLeft
frmY = frmHeight / 2 + frmTop
dx = AppCenterX - frmX
dy = AppCenterY - frmY
leftNew = frmLeft + dx
topNew = frmTop + dy
If leftNew < 0 Then
leftNew = 0
End If
If topNew < 0 Then
topNew = 0
End If
If frmHeight > AppH * dblCfnt Then
frmHeight = AppH * dblCfnt
End If
If frmWidth > AppW * dblCfnt Then
frmWidth = AppW * dblCfnt
End If
frm.Move leftNew, topNew, frmWidth, frmHeight
End If
End If
centerFormOnAppWindow = res
exit_func:
Set frm = Nothing
Exit Function
err_Func:
errS = Err.Number & ": " & Err.Description & " (" & Err.Source & ")"
Debug.Print errS
centerFormOnAppWindow = 0
Resume exit_func
End Function