Bonjour, Je voudrais enregistrer une partie de ma page en PDF dans un fichier avec un certains nom et remplisse un certains tableau mais mon code dit qu'il a un problème avec le code ActiveSheet. Pouvez-vous m'aider?
ActiveSheet.Range("A1:H45").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
Chemin & nom & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=True
Voici mon code de base :
Sub Cree_Pdf()
Dim Chemin$, nom$, num$, txt$
Application.ScreenUpdating = False
With Feuil19
.Activate
.Range("s2") = .Range("s2") + 1
.Range("a1") = "N°" & .Range("s2")
num = .Range("a1").Value
End With
ActiveSheet.Copy
Chemin = "\PDF FICHE DE TRAVAIL\"
nom = "Fiche De Travail_" & num & "_ du _" & Format(Date, "dd-mm-yyyy")
ActiveSheet.Range("A1:H45").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
Chemin & nom & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=True
With Feuil20
Lig = .Cells(Rows.Count, "A").End(xlUp).Row + 1
.Cells(Lig, "A") = num
Lig = .Cells(Rows.Count, "B").End(xlUp).Row + 1
.Cells(Lig, "B") = Format(Date, "dd-mm-yyyy")
Lig = .Cells(Rows.Count, "E").End(xlUp).Row + 1
.Cells(Lig, "E") = Range("E12")
Lig = .Cells(Rows.Count, "F").End(xlUp).Row + 1
.Cells(Lig, "F") = Range("G12")
Lig = .Cells(Rows.Count, "C").End(xlUp).Row + 1
.Cells(Lig, "C") = Range("B21")
Lig = .Cells(Rows.Count, "G").End(xlUp).Row + 1
.Cells(Lig, "G") = Range("C14")
Lig = .Cells(Rows.Count, "D").End(xlUp).Row + 1
.Cells(Lig, "D") = Range("D17")
Lig = .Cells(Rows.Count, "H").End(xlUp).Row + 1
.Cells(Lig, "H") = Range("D18")
Lig = .Cells(Rows.Count, "I").End(xlUp).Row + 1
.Cells(Lig, "I") = nom
End With
ActiveWorkbook.Close False
End Sub