Public Sub UserformZoomEcran(Usf As Object)
Dim RW@, RH@, PtToPx#, PosTop@, FMaxUserfWidth@, FMaxUserfHeight@
'avec Excel supp 2003 (à cause de ActivePane)
'PtToPx = ((ActiveWindow.ActivePane.PointsToScreenPixelsX(ActiveSheet.[A1].Width) - ActiveWindow.ActivePane.PointsToScreenPixelsX(0)) / ActiveSheet.[A1].Width) / (ActiveWindow.Zoom / 100)
'PosTop = ActiveWindow.ActivePane.PointsToScreenPixelsY(Cells(1, 1).Top) / PtToPx
'avec excel 2003
PtToPx = CreateObject("WScript.Shell").RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager\LastLoadedDPI") / 72
PosTop = ActiveWindow.PointsToScreenPixelsY(Cells(1, 1).Top) / PtToPx
FMaxUserfWidth = Application.Width - 12
FMaxUserfHeight = Application.Height + 18 - 30 - PosTop '30=HautBarreTache
With Usf
.StartUpPosition = 0: .Top = 0: .Left = 0 'position 0
RW = .Width / .Zoom: RH = .Height / .Zoom 'agrandi au max
While .Width < FMaxUserfWidth And .Height < FMaxUserfHeight And .Zoom < 400
.Zoom = .Zoom + 1: .Width = .Zoom * RW: .Height = .Zoom * RH
Wend
RW = .Width / .Zoom: RH = .Height / .Zoom 'diminue si trop grand
While (.Width > FMaxUserfWidth Or .Height > FMaxUserfHeight) And .Zoom > 10
.Zoom = .Zoom - 1: .Width = .Zoom * RW: .Height = .Zoom * RH
Wend
End With
With Usf: .Top = PosTop: .Left = (FMaxUserfWidth - .Width) * 0.5: End With 'centre
End Sub