Enregistrer en PDF

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

Salut,

Essaye de rajouter un .Select à ton code, sinon tu peux créer une zone d'impression pour cette feuille ^^.

Bonjour

personnellement je penses qu'il y a un problème sur le chemin d'enregistrement...

 Chemin = "\PDF FICHE DE TRAVAIL\"

le chemin doit contenir tout le chemin... exemple :

 Chemin = "C:\Users\Fred\Desktop\PDF FICHE DE TRAVAIL\"

mais il faut être sur que le dossier existe...

si c'est un sous dossier du fichier dans lequel s'execute cette macro :

 Chemin = thisworkbook.path & "\PDF FICHE DE TRAVAIL\"

Fred

Bonjour, sa ne change toujours rien, j'ai toujours le même problème

J'ai trouvé merci a tous

Bonjour...

c'est bien de répondre presque 2 ans après !!!!

bon maintenant

on va peut-être attendre un peu moins longtemps ?? !!!

Fred

Rechercher des sujets similaires à "enregistrer pdf"