1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| Function PositionForm(FORM As Object, rng As Range)
Dim G As Double, D As Double, K As Double, Z As Double
Z = ActiveWindow.Zoom / 100
K = GetDeviceCaps(GetDC(0), 88) / 72
G = ActiveWindow.PointsToScreenPixelsX(rng.Left * K * Z) / K
D = ActiveWindow.PointsToScreenPixelsX((rng.Left + rng.Width) * K * Z) / K
K = GetDeviceCaps(GetDC(0), 90) / 72
'lleft = ActiveWindow.PointsToScreenPixelsX(rng.Left * K * Z) / K - 0 '==> on va essayer autrement
ttop = ActiveWindow.PointsToScreenPixelsY(rng.Top * K * Z) / K
corr = (ActiveWindow.Width - ActiveWindow.UsableWidth + 3) * Z
lleft = Application.Left + ActiveWindow.Left + corr + (ActiveCell.Left * ActiveWindow.Zoom / 100)
PositionForm = Array(lleft, ttop)
End Function
Private Sub CommandButton5_Click()
Z = ActiveWindow.Zoom / 100
r = PositionForm(UserForm1, ActiveCell)
With UserForm1
.Show 0: .Left = r(0): .Top = r(1)
End With
End Sub |