Bonjour le fofo,

Voilà en cherchant à droite à gauche j'ai adapté un code pour redimensionner un Userform lors de son lancement:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 
Public Declare Function FindWindowA Lib "user32" _
        (ByVal lpClassName As String, ByVal lpWindowName As String) As Long '
Public Declare Function GetWindowLong Lib "user32" Alias _
        "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
 
Function ResizeUserForm(UForm As Object)
Dim hwnd As Long, exlong As Long, factor As Integer, zfactor As Integer
Dim UCaption As String
 
UCaption = UForm.Caption
hwnd = FindWindowA(vbNullString, UCaption)
exlong = GetWindowLong(hwnd, -16)
 
        zfactor = 1000 * (Application.Width / (UForm.Width + 20))
        factor = 1000 * (Application.Height / (UForm.Height + 20))
 
If factor < 1000 Then
    PrAc = CInt(((1000 - factor) / factor) * 100 + 1)
    Zoom = 100 + PrAc
UForm.Width = UForm.Width / (Zoom / 100)
UForm.Height = UForm.Height / (Zoom / 100)
If PrAc > 5 Then
    UForm.Zoom = 200 - (Zoom - 5)
Else
    UForm.Zoom = 200 - Zoom
End If
End If
If zfactor < 1000 Then
'rien pour l'instant
 
End If
End Function
Seul soucis, le code s'applique selon la taille de la fenêtre de l'application Excel et non celle de la résolution de l'écran.

Quelqu'un aurait une idée?

Merci