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
| Sub essai_impression()
'
' Essai sur les impressions du cahier (lot groupes par 2)
'
Dim a As Long
Dim sNomFichierPDF As String
Dim i As Long, Cpt As Long
Dim Ar() As String, c As String, d As Long
Application.ScreenUpdating = False
For a = 1 To ThisWorkbook.Sheets.Count
'selectionne les feuilles nommées lot
If Left(Sheets(a).Name, 4) = "lot " Then
b = CInt(Right(Sheets(a).Name, Len(Sheets(a).Name) - 4))
'si l'index est impair
If b Mod 2 <> 0 Then
Sheets("lot " & b).Range("B2:L27").Copy
With Sheets("Feuil2")
.Range("B2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
.Range("B2").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End With
Else
'si l'index est pair
Sheets("lot " & b).Range("B2:L27").Copy
With Sheets("Feuil2")
.Range("B35").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
.Range("B35").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End With
With Sheets("Feuil2")
.PageSetup.PrintArea = "$B$2:$L$60"
.PageSetup.Zoom = False
.PageSetup.FitToPagesTall = 1
.PageSetup.FitToPagesWide = 1
sNomFichierPDF = ThisWorkbook.Path & "\" & "lot " & .Range("E2").Value & " et " & .Range("E35").Value & ".pdf"
c = .Range("E2").Value & "et" & .Range("E35").Value
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sNomFichierPDF _
, Quality:=xlQualityMinimum, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
.Range("B2:L60").Clear
End With
Application.CutCopyMode = False
End If
End If
Next a
'si le nombre total des feuille "lot" est impair alors impression de la derniere feuille "lot "
If b Mod 2 <> 0 Then
With Sheets("Feuil2")
sNomFichierPDF = ThisWorkbook.Path & "\" & "lot " & .Range("E2").Value & ".pdf"
.PageSetup.PrintArea = "$B$2:$L$60"
.PageSetup.Zoom = False
.PageSetup.FitToPagesTall = 1
.PageSetup.FitToPagesWide = 1
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sNomFichierPDF _
, Quality:=xlQualityMinimum, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
.Range("B2:L60").Clear
End With
End If
Application.CutCopyMode = False
Sheets("ACCUEIL").Select
Application.ScreenUpdating = True
End Sub |
Partager