Private Sub UserForm_Initialize()
Dim H&, W&, T&, CtrL, CtrL2, f, a&, ecX&, VueMax
H = 25 'hauteur des controls
W = 150 'largeur des controls de gauche(les noms de feuille)
T = 5 'le top de depart
ecX = 3 'espaces entre les controls
VueMax = 10 'nombre de feuille visible dans le dialogue avant la scroll
'titre
Set CtrL = Me.Controls.Add("Forms.Label.1", "titleFN", True)
With CtrL: .Caption = "Feuille à imprimer": .Move 5, 1, W, H: .BorderStyle = 1: .TextAlign = 2: .ForeColor = vbWhite
.Font.Size = 14: End With
Set CtrL2 = Me.Controls.Add("Forms.Label.1", "titleNB", True)
With CtrL2: .Caption = "Copies": .Move CtrL.Left + CtrL.Width + 5, 1, 60, H: .BorderStyle = 1: .TextAlign = 2: .ForeColor = vbWhite
.Font.Size = 14: End With
'Liste des feuilles à imprimer
For Each f In ThisWorkbook.Sheets
a = a + 1
Set CtrL = Me.Frame1.Controls.Add("Forms.Label.1", "title" & a, True)
With CtrL: .Caption = f.Name & " : ": .Move 5, T, W, H: .BorderStyle = 1: .TextAlign = 2: .Font.Size = 14: End With
Set CtrL2 = Me.Frame1.Controls.Add("Forms.textbox.1", "NBC" & a, True)
With CtrL2: .Tag = f.Name: .Move CtrL.Left + CtrL.Width + 5, T, 60, H: .Font.Size = 14: End With
T = T + H + ecX
Next
'VueMax = a 'pour faire peter la limite de vuemax bien sur si l'ecran le permet
'redimensionnement du userform ,de la frame + scrollbars si necessaire, placement du bouton
'pour un visuel aisé la frame est limité à 10 feuilles
'au dela de 10 feuilles la frame a une scrollbar verticale
With Frame1
.Move 1, (H + ecX), CtrL2.Left + CtrL2.Width + 10, (H + ecX) * VueMax
If CtrL2.Top + H > ((H + ecX) * VueMax) + 5 Then .ScrollBars = 2: .ScrollHeight = CtrL2.Top + H: .Width = .Width + 10
End With
Me.Width = Frame1.Width + 5 + 1
Me.Height = Frame1.Height + Frame1.Top + 50
BtImprim.Move 0, Me.InsideHeight - H - 2, Me.Width, H
BtImprim.Font.Size = 14
End Sub
Private Sub BtImprim_Click()
Dim CtrLx
For Each CtrLx In Frame1.Controls
If CtrLx.Tag <> "" Then If CtrLx.Value <> "" Then Sheets(CtrLx.Tag).PrintOut Copies:=Val(CtrLx.Value), Collate:=False
Next
End Sub