PDF-Creator hängt sich manchmal auf

Hi,

ich benutze den folgenden Code um aus Word heraus eine PDF-Datei zu erzeugen. Es funktioniert auch meistens, aber manchmal wird der PDF-Creator nicht beendet und ich muss den Task-Manager aufrufen um ihn zu beenden. Meistens passiert dies beim ersten mal und bei den nächsten Druckvergängen nicht mehr. Ist der Code ok ? Ich benutze übrigens Windows-XP.

Gruß Thomas !

 

 

Private WithEvents PDFJob As PDFCreator.clsPDFCreator

Private Sub UserForm_Initialize()

On Error Resume Next
If Len(ActiveDocument.Path) = 0 Then
   MsgBox "Bitte zuerst das Dokument speichern !", vbExclamation
   End
End If
Set PDFJob = New clsPDFCreator
With PDFJob
   If .cStart("/NoProcessingAtStartup") = False Then
      cmdPDFCr.Enabled = False
      AddStatus "PDFCreator kann nicht initialisiert werden !"
      Exit Sub
   End If
End With

'verschiedene Optionen werden ausgelesen
cbPDFUseSecurity = lPS(Pd$, "PDFUseSecurity", "0")
cbPDFDisallowCopy = lPS(Pd$, "PDFDisallowCopy", "0")
cbPDFDisallowModifyContents = lPS(Pd$, "PDFDisallowModifyContents", "0")
tbPDFOwnerPasswordString = lPS(Pd$, "PDFOwnerPasswordString", "eG&9/kx3")
AddStatus "PDFCreator wurde initialiert."
Call cbPDFUseSecurity_Change
End Sub

Private Sub cbPDFUseSecurity_Change()
On Error Resume Next
If cbPDFUseSecurity Then
   cbPDFDisallowModifyContents.Enabled = True
   cbPDFDisallowCopy.Enabled = True
   tbPDFOwnerPasswordString.Enabled = True
Else
   cbPDFDisallowModifyContents.Enabled = False
   cbPDFDisallowCopy.Enabled = False
   tbPDFOwnerPasswordString.Enabled = False
End If
End Sub


Private Sub cmdPDFCr_Click()
Dim outName$
cmdEnde.Enabled = False
If InStr(1, ActiveDocument.Name, ".", vbTextCompare) > 1 Then
   outName$ = Mid(ActiveDocument.Name, 1, InStr(1, ActiveDocument.Name, ".", vbTextCompare) - 1)
Else
   outName$ = ActiveDocument.Name
End If
cmdPDFCr.Enabled = False
With PDFJob
   .cOption("UseAutosave") = 1
   .cOption("UseAutosaveDirectory") = 1
   .cOption("AutosaveStartStandardProgram") = 0
   .cOption("SendEmailAfterAutoSaving") = 0
   .cOption("ProcessPriority") = 2
  
   .cOption("AutosaveDirectory") = ActiveDocument.Path
   .cOption("AutosaveFilename") = Emp$ & outName
   .cOption("AutosaveFormat") = 0       ' 0 = PDF
  
   .cOption("PDFUseSecurity") = cbPDFUseSecurity
   .cOption("PDFLowEncryption") = 1
   .cOption("PDFOwnerPass") = 1
   .cOption("PDFOwnerPasswordString") = tbPDFOwnerPasswordString
  
   .cOption("PDFDisallowCopy") = cbPDFDisallowCopy
   .cOption("PDFDisallowModifyContents") = cbPDFDisallowModifyContents
   'MsgBox "PDFCompressionColorCompression = ", .cOption("PDFCompressionColorCompression")
   .cClearCache
End With
DoEvents
If ufGADrucken.cbAlles Then
   ActiveDocument.PrintOut Background:=0
Else
   v$ = ufGADrucken.Tag
   If v$ <> "" Then ActiveDocument.PrintOut Range:=wdPrintRangeOfPages, Pages:=v$, Background:=0
End If
AddStatus "Start PDF-Erstellung..."
DoEvents
PDFJob.cPrinterStop = False
End Sub


Private Sub PDFJob_eError()
AddStatus "ERROR [" & PDFJob.cErrorDetail("Number") & "]: " & PDFJob.cErrorDetail("Description")
End Sub

Private Sub PDFJob_eReady()
AddStatus "Datei'" & PDFJob.cOutputFilename & "' wurde gespeichert."
PDFJob.cPrinterStop = True
cmdPDFCr.Enabled = True
cmdEnde.Enabled = True
ufMail.Tag = PDFJob.cOutputFilename
End Sub


Private Sub AddStatus(Str1 As String)
With tbStatus
 If Len(.Text) = 0 Then
   .Text = Now & ": " & Str1
  Else
   .Text = .Text & vbCrLf & Now & ": " & Str1
 End If
 .SelStart = Len(.Text)
 .SetFocus
End With
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, Closemode As Integer)
PDFJob.cClose
Set PDFJob = Nothing
Sleep 250
DoEvents
On Error Resume Next
sPS Pd$, "PDFUseSecurity", IIf(cbPDFUseSecurity, "1", "0")
sPS Pd$, "PDFDisallowCopy", IIf(cbPDFDisallowCopy, "1", "0")
sPS Pd$, "PDFDisallowModifyContents", IIf(cbPDFDisallowModifyContents, "1", "0")
sPS Pd$, "PDFOwnerPasswordString", tbPDFOwnerPasswordString
End Sub

Private Sub cmdEnde_Click()
Unload Me
End Sub

Hi,

also ich installiere immer die neuste Version, habe jedoch bisher keinen Unterschied bezüglich meines Problemes feststellen können, auch unter der Version 1.0.1 hängt er sich beim Beenden manchmal auf.

Gruss Thomas