Citation:
Envoyé par
patricktoulon
marc oui zoom a 100 avec un autre zoom c'est la bérézina
Extrait d'un code ici simplifié & testé ce jour sur Excel 2003 & 2010 32 bits (le portable avec 2007 n'étant pas rentré)
sur des versions de Windows différentes (Seven & 8.1) avec des profondeurs d'écran différentes (96 & 120 dpi)
uniquement pour un zoom à 100% et calant la fenêtre de l'UserForm sur la cellule D3,
code à placer dans le module de l'UserForm :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Private Declare Function GetDC& Lib "user32" (ByVal hWnd&)
Private Declare Function GetDeviceCaps& Lib "gdi32" (ByVal hdc&, ByVal nIndex&)
Function GetPPI!(L&)
GetPPI = 72 / GetDeviceCaps(GetDC(0), L)
End Function
Static Function GetX!(V)
If X! = 0 Then X = GetPPI(88)
GetX = 4 + ActiveWindow.PointsToScreenPixelsX(V / X) * X
End Function
Static Function GetY!(V)
If Y! = 0 Then Y = GetPPI(90)
GetY = 4 + ActiveWindow.PointsToScreenPixelsY(V / Y) * Y
End Function
Private Sub UserForm_Activate()
If ActiveWindow.Zoom = 100 Then
Me.StartUpPosition = 0
Me.Left = GetX([D3].Left)
Me.Top = GetY([D3].Top)
End If
End Sub |