Dim G As Double, D As Double, H As Double, B As Double, U As Object, K As Double, Z As Double, Pge As MSForms.Page
If TypeOf Obj Is MSForms.Control Then
G = Obj.Left: H = Obj.Top: Set U = Obj.Parent
Do:
If TypeOf U Is MSForms.Page Then
Set Pge = U: Set U = U.Parent: K = (U.Width - Pge.InsideWidth) / 2
G = G + U.Left + K: H = H + U.Top + U.Height - Pge.InsideHeight - K
Else
K = (U.Width - U.InsideWidth) / 2
G = G + U.Left + K: H = H + U.Top + U.Height - U.InsideHeight - K
End If
If Not (TypeOf U Is MSForms.Frame Or TypeOf U Is MSForms.MultiPage) Then Exit Do
Set U = U.Parent: Loop
D = G + Obj.Width: B = H + Obj.Height
Else
Z = ActiveWindow.Zoom / 100
K = GetDeviceCaps(GetDC(0), 88) / 72
G = ActiveWindow.PointsToScreenPixelsX(Obj.Left * K * Z) / K
D = ActiveWindow.PointsToScreenPixelsX((Obj.Left + Obj.Width) * K * Z) / K
K = GetDeviceCaps(GetDC(0), 90) / 72
H = ActiveWindow.PointsToScreenPixelsY(Obj.Top * K * Z) / K
B = ActiveWindow.PointsToScreenPixelsY((Obj.Top + Obj.Height) * K * Z) / K
End If
Me.Left = (X * (D - G + Me.Width + 6) + G + D - Me.Width - 6) / 2 + 3
Me.Top = (Y * (B - H + Me.Height + 6) + H + B - Me.Height - 6) / 2 + 3
End Sub