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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
| Sub EnregisterProjetDecompte2()
'
' EnregisterProjetDecompte
Calculate
Range("A1:G630").Select
Selection.Copy
Dim Emplacement As String
Emplacement = Cells(10, 3)
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
Selection.PasteSpecial Paste:=xlPasteColumnWidths
' largeur colonne'
Columns("A:A").ColumnWidth = 0
Columns("B:B").ColumnWidth = 10
Columns("C:C").ColumnWidth = 48
Columns("D:D").ColumnWidth = 5
Columns("E:E").ColumnWidth = 7
Columns("F:F").ColumnWidth = 10
Columns("G:G").ColumnWidth = 12
' HAUTEUR des lignes
Rows.AutoFit
' Select enreg avec code<>0
ActiveSheet.Range("$A$5:$A$630").AutoFilter Field:=1, Criteria1:="1", _
Operator:=xlAnd
' mise en page MARGES '
With ActiveSheet.PageSetup
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0.196850393700787)
.RightMargin = Application.InchesToPoints(0.196850393700787)
.TopMargin = Application.InchesToPoints(0.9)
.BottomMargin = Application.InchesToPoints(0.590551181102362)
.HeaderMargin = Application.InchesToPoints(0.196850393700787)
.FooterMargin = Application.InchesToPoints(0.393700787401575)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = True
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
End With
' fin de mise en page marges '
' Mise en page en portrait avec date impression et n° page ; le tout dans 1 seule page avec logo'
ActiveSheet.PageSetup.PrintArea = "$A$1:$G$630"
With ActiveSheet.PageSetup
.LeftHeaderPicture.Filename = _
"C:\Users\NOM DU FICHIER.JPG"
.RightHeader = "Page &P de &N"
.LeftHeader = "&G"
.Orientation = xlPortrait
.LeftFooter = "adresse Socièté"
.CenterFooterPicture.Filename = _
"C:\Users\LOGO.jpg"
.CenterFooter = "&G"
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
'----------Enregistrement sous nom de fichier à sauvegarder ------------
If Emplacement <> "" Then
' désignation emplacement des fichiers sauvegardés '
ChDir "C:\Users\NOM DU DOSSIER" '
Application.DisplayAlerts = False
' création fichier XLS '
fichier = Emplacement & "_" & Format(Now, "yyyy-mm-dd-hhmmss")
nomFichier = "X1" & ".xls"
ActiveWorkbook.SaveAs Filename:=nomFichier, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
' création fichier PDF'
fichier = Emplacement & "_" & Format(Now, "yyyy-mm-dd-hhmmss")
nomFichier2 = "Projet_" & fichier & ".pdf"
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=nomFichier2, _
Quality:=xlQualityStandard, OpenAfterPublish:=True
' Fermeture tableau excel ... mais il est quand meme enregistré '
Workbooks(X1.xls).Close SaveChanges:=False
Else
Answer = MsgBox(Prompt:=" Le nom du fichier n'est pas spécifié (Cellule C10), l'enregistrement n'est pas fait.", Buttons:=vbYes)
End If
' EffaceProjetDécompte
ActiveWindow.SmallScroll Down:=6
Range("C10,E15:E606,E609").Select
Range("E609").Activate
Selection.ClearContents
ActiveWindow.ScrollRow = 1
Range("C10").Select
End Sub |
Partager