Private Sub placementUF(ByVal Obj As Object)
If Not Obj Is Nothing Then
Dim Lft As Double, Rgt As Double, Top As Double, Bot As Double, P As Object, PInsWidth As Double, PInsHeight As Double
Dim K As Double, Zom As Double, Ombre As double
Ombre = 2
Lft = Obj.Left: Top = Obj.Top: Set P = Obj.Parent ' Normalement Page, Frame ou UserForm
Do
PInsWidth = P.InsideWidth: PInsHeight = P.InsideHeight ' Le Page en est pourvu, mais pas le Multipage.
If TypeOf P Is MSForms.Page Then Set P = P.Parent ' Prend le Multipage, car le Page est sans positionnement.
K = (P.Width - PInsWidth) / 2
Debug.Print TypeName(P) & " " & K
Lft = (Lft + P.Left + K)
Top = (Top + P.Top + P.Height - K - PInsHeight)
If Not (TypeOf P Is MSForms.Frame Or TypeOf P Is MSForms.MultiPage) Then Exit Do
Set P = P.Parent
Loop
Me.Left = Lft + 1 + Ombre + Obj.Width ' a droite de obj
Me.Top = Top + 2 + Ombre 'au top de obj
End If
End Sub
Ce qui se traduit à la fin par :' X: -1: Collé au coté gauche, 0: Centré horizontalement, 1: Collé au coté droit.
' Y: -1: Collé au bord supérieur, 0: Centré verticalement, 1: Collé juste en dessous.
' Mais si la valeur absolue de X >= 1, Y:=0.9 est une valeur conventionnelle signifiant
' que le bord supérieur du calendrier doit être aligné sur celui de Obj.
If Abs(X) >= 1 And Y = 0.9 Then Me.Top = Top Else _
Me.Top = (Y * (Bot - Top + Me.Height + 6) + Top + Bot - Me.Height - 6) / 2 + 3
Tu veux dire que mon calcul n'est pas bon en Excel 2007 ?
Zom = ActiveWindow.Zoom / 100
If ActiveWindow.FreezePanes And Obj.Column >= ActiveWindow.ScrollColumn Then
Lft = ActiveWindow.ActivePane.PointsToScreenPixelsX(Int(Obj.Left * Zom + 0.5)) * 3 / 4
Else
Lft = ActiveWindow.PointsToScreenPixelsX(Int(Obj.Left * Zom * 4 / 3 + 0.5)) * 3 / 4
End If
If ActiveWindow.FreezePanes And Obj.Row >= ActiveWindow.ScrollRow Then
Top = ActiveWindow.ActivePane.PointsToScreenPixelsY(Int(Obj.Top * Zom + 0.5)) * 3 / 4
Else
Top = ActiveWindow.PointsToScreenPixelsY(Int(Obj.Top * Zom * 4 / 3 + 0.5)) * 3 / 4
End If
Rgt = Lft + Obj.Width * Zom: Bot = Top + Obj.Height * Zom
Sub test()
Debug.Print "ss:DefaultColumnWidth" & Split(Split([B3].Value(xlRangeValueXMLSpreadsheet), "ss:DefaultColumnWidth")(1), vbCrLf)(0)
Debug.Print [B3].Width & ", " & [B3].Height
End Sub