Message "PDFCreator n'a pu être démarrer"

jlp035

XLDnaute Occasionnel
Bonjour,
étant débutant en vba j'ai recuperer un morceau de programme pour imprimer une feuille en pdf , mais lors du lancement du programme Pdf creator ne semble pas se lancer ?
Une personne plus qualifié que moi connait 'elle la solution au problème.

Merci par avance
Code:

Sub ImprPdf()
Dim pdfjob As Object
Dim myprint As String
Dim Port As Integer
Dim Q As String
Dim NoMFichier As String
Dim fichname As String
Dim Destin As String
Dim txt As String
Dim NomPdf As String
Dim DefaultPrinter As String
Dim Crd As String
Dim Soc As String
Dim The As String

Crd = Range("AA6") ' Chemin du repertoire Documents
Soc = Range("O11") ' Nom Sociètè
The = Range("B21") ' Thème

Q = ""
For Port = 0 To 9 ' test tous les port imprimantes pour activer pdfCreator en imprimante active

myprint = "PDFCreator sur Ne0" & Port & ":"
On Error Resume Next
If ActivePrinter = myprint Then
Exit For
End If
Next
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
With pdfjob
If .cstart("/NoProcessingAtStartup") = False Then ' démarre Pdf Creator en cas de probleme il te le dit
MsgBox " PDFCreator n'a pu être démarrer.", vbCritical + vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
End With


NoMFichier = "Récapitulatif " & Soc & " " & Format(Date, "yyyy_mm_dd") & " " & Format(Time, "hh_mm") & " " & The ' détermine le non de ton fichier
fichname = ThisWorkbook.Path & "\" & NoMFichier & ".pdf" ' tu choisit où tu veux que ton fichier soit enregistrer
Destin = fichname
txt = Dir(Destin, vbNormal) ' test te permettant de savoir si un fichier du m^me nom existe déja
If txt <> "" Then
MsgBox "Ce récapitulatif existe déja"
Exit Sub
End If
NomPdf = NoMFichier & ".pdf"
With pdfjob ' application de la configuration demandé plus haut ( nom et chemin du fichier)
.cOption("UseAutosave") = 1
.cOption("UseAutisaveDirectory") = 1
.cOption("AutosaveDirectory") = (ThisWorkbook.Path)
.cOption("AutosaveFilename") = NomPdf
.cOption("AutosaveFormat") = 0
.cClearCache
DefaultPrinter = .cDefaultprinter
End With
ThisWorkbook.Worksheets("Récapitulatif").PrintOut Copies:=1, ActivePrinter:=Q & myprint & Q
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
Call Sleep(750)
With pdfjob
.cDefaultprinter = DefaultPrinter
.cClearCache
End With
Set pdfjob = Nothing
MsgBox ("Le nom de votre fichier : " & NomPdf)
MsgBox (" Le chemin de ce fichier est : " & ThisWorkbook.Path)
End Sub
 

kiki29

XLDnaute Barbatruc
Re : Message "PDFCreator n'a pu être démarrer"

Salut, voir en ajoutant un TaskKill

Code:
Private Sub KillPDFCreator()
Dim RetVal As Long
    RetVal = Shell("Taskkill /im PDFCreator.exe /f", 0)
End Sub

Mais pas sur que cela suffise, pas testé ton code, qui ressemble à un dramatique copier/coller
 
Dernière édition:

Statistiques des forums

Discussions
312 232
Messages
2 086 462
Membres
103 222
dernier inscrit
2BS