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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
Sub incrementeditionetiamazon()
Dim Fe As Worksheet
Dim Ctrl As OLEObject
Dim LblProgress As MSForms.Label
Dim LblFond As MSForms.Label
Dim LargeurLabel As Integer
Dim HauteurLabel As Integer
Dim R As Double
Dim I As Long
Dim x As Long
Set Fe = Worksheets("Feuil1")
'supprime les labels si par hazard ils existent
'gère l'erreur dans le cas contraire
On Error Resume Next
Fe.Shapes("LblProgress").Delete
Fe.Shapes("LblFond").Delete
On Error GoTo 0
'défini les dimensions
LargeurLabel = 500
HauteurLabel = 20
With Fe
'crée le label servant de fond
Set Ctrl = .OLEObjects.Add(ClassType:="Forms.Label.1", _
Link:=False, _
DisplayAsIcon:=False, _
Left:=Application.UsableWidth / 2 - LargeurLabel / 2, _
Top:=Application.UsableHeight / 2, _
Width:=LargeurLabel, _
Height:=HauteurLabel)
'passe l'objet à la variable afin d'utiliser les propriétés des labels
Set LblFond = Ctrl.Object
'défini certaines de ces dernières
With LblFond
.Name = "LblFond"
.Caption = ""
.BorderColor = vbBlue
.BorderStyle = fmBorderStyleSingle
End With
'crée le label servant de barre de progression
Set Ctrl = .OLEObjects.Add(ClassType:="Forms.Label.1", _
Link:=False, _
DisplayAsIcon:=False, _
Left:=Application.UsableWidth / 2 - LargeurLabel / 2, _
Top:=Application.UsableHeight / 2, _
Width:=0, _
Height:=HauteurLabel)
'idem que plus haut
Set LblProgress = Ctrl.Object
With LblProgress
.Name = "LblProgress"
.Caption = ""
.BackColor = vbBlue
End With
End With
'rapport
R = LargeurLabel / Range("Z29")
'boucle d'impression
For x = 1 To Range("Z29")
Range("R19").Value = Range("R19").Value + 1
LblProgress.Width = x * R
DoEvents
ActiveWindow.SelectedSheets.PrintOut Copies:=Cells(29, 11).Value
Next x
'destruction des labels
On Error Resume Next
Fe.Shapes("LblProgress").Delete
Fe.Shapes("LblFond").Delete
On Error GoTo 0
Set Fe = Nothing
Set Ctrl = Nothing
Set LblProgress = Nothing
Set LblFond = Nothing
End Sub |
Partager