Erreur 1004 - PrintOut
Bonjour, c'est la première fois que je reste bloqué sur un sujet.
j'ai un problème avec mes fonctions VBA
J'ai une fonction export en PDF et une fonction impression, toutes deux utilisent des boutons différents
Si j'utile la fonction export seulement : Export OK
Si j'utile la fonction impression seulement : Impression OK
Si j'utile la fonction export puis la fonction impression : Export OK, impression NOK
Si j'utile la fonction impression puis la fonction export : impression OK, export OK
Si j'utile la fonction impression puis la fonction export et ensuite l'impression : impression OK, export OK, impression NOK.
Dès que j'utilise l'export, l'impression ne fonctionne plus. Il y a l'erreur : la méthode PrintOut de la classe Worksheet a échoué
Voici mes 2 fonctions :
Sub impression_facture()
ActiveSheet.PrintOut Copies:=1, Collate:=False, IgnorePrintAreas:=False, Preview:=False
End Sub
Sub export_pdf()
Dim FileName As String, folderPath As String
FileName = Sheets("Facture").Range("B5").Value
folderPath = ThisWorkbook.Path
' Exporter en PDF
Sheets("FACTURE MODELE").ExportAsFixedFormat Type:=xlTypePDF, FileName:=folderPath & "/" & FileName
' Afficher le dialogue d'impression
MsgBox "Le fichier PDF a été créé avec succès à l'emplacement : " & vbCrLf & folderPath & "/" & FileName & ".pdf" & vbCrLf & vbCrLf & "Veuillez imprimer le fichier manuellement.", vbInformation, "Exportation PDF réussie"
End SubEdit modo : code à mettre entre balises avec le bouton </> merci d'y faire attention la prochaine fois
Bonsoir,
je n'y connais pas grand chose en gestion de fichier et/ou impression sous Excel... Mais je vous propose ceci :
Sub export_pdf()
' Exporter en PDF
Sheets("FACTURE MODELE").ExportAsFixedFormat _
Type:=xlTypePDF, _
FileName:=ThisWorkbook.Path & "\" & Sheets("Facture").Range("B5").Value & ".pdf"
' Afficher le dialogue d'impression
MsgBox "Le fichier PDF a été créé avec succès à l'emplacement : " & vbCrLf & ThisWorkbook.Path & "\" & Sheets("Facture").Range("B5").Value & ".pdf" & vbCrLf & vbCrLf & "Veuillez imprimer le fichier manuellement.", vbInformation, "Exportation PDF réussie"
End Sub@ bientôt
LouReeD