Private Sub placementUF()
Dim EcX#, EcY#, X#, Y#
If Not obj Is Nothing Then
EcX = Me.Width - Me.InsideWidth
EcY = Me.Height - Me.InsideHeight
X = obj.Left + obj.Width + EcX: Y = obj.Top + obj.Height
'Do Until TypeOf obj Is UserForm
'Do While TypeName(obj) = "UserForm"
Debug.Print obj.Name
Set obj = obj.Parent
If TypeName(obj) = "Page" Then Set obj = obj.Parent: Y = Y + (EcX * 3)
X = X + obj.Left + (EcX / 2): Y = Y + obj.Top + (EcX + (EcX / 2))
Loop
Me.Left = X
Me.Top = Y
End If
End Sub
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
Private Function PtoPx()
With ActiveWindow.ActivePane:
PtoPx = (.PointsToScreenPixelsX(Cells.Width) - .PointsToScreenPixelsX(0)) / Cells.Width
End With
End Function
Private Sub UserForm_Activate()
Dim EcX#, L1, T1#, zooom#
EcX = Me.Width - Me.InsideWidth 'ne doit pas subir le zoom
zooom = (ActiveWindow.Zoom / 100)
deb = Application.Left 'ne doit pas subir le zoom
L1 = (ActiveWindow.ActivePane.PointsToScreenPixelsX(0) / PtoPx) * zooom 'subi le zoom
T1 = (ActiveWindow.ActivePane.PointsToScreenPixelsY(0) / PtoPx) * zooom
Me.Left = L1 + (Range([b3], Cells(1, 1)).Width * zooom) + EcX
Me.Top = T1 + (Range([b3].Offset(-1), Cells(1, 1)).Height * zooom) + EcX
End Sub