PDF-Creator vs CutePDF
19.07.2013 11:30:28
Ralf
habe das Problem,dass ich einen neuen Rechner bekommen habe und statt PDF-Creator den CutePDF verwenden muss. Wie muss ich den nachfolgenden Code ändern, damit das mit dem CutePDF funktioniert?
Danke für die Hilfe
Gruß Ralf
Sub LMKS_PDF_drucken()
Dim pdfjob As PDFCreator.clsPDFCreator
'Dim pdfjob As Object
Dim sPDFName As String
Dim sPDFPath As String
'PDF-Dateinamen festlegen
sPDFName = "LMKS_" & Worksheets("LMKS").Range("K10").Value & " # " & Worksheets("LMKS").Range( _
_
"R1").Value & ".pdf"
sPDFPath = "Y:\OTM\sped_13\LMKS" & Application.PathSeparator
'sPDFPath = ActiveWorkbook.Path & Application.PathSeparator
'Prüfung ob das Arbeitsblatt leer ist; wenn ja dann Programm-Ende
If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub
'Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
Set pdfjob = New PDFCreator.clsPDFCreator
With pdfjob
'Sicherstellen, dass der PDFCreator startet
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
'Standardwerte setzen
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With
'PDF drucken
ActiveSheet.PrintOut copies:=1, ActivePrinter:="PDFCreator"
'Warten, bis der Druckjob zum Drucken gekommen ist
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
'Warten, bis PDFCreator gedruckt hat; dann Freigabe des Objekts
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
pdfjob.cClose
Set pdfjob = Nothing
End Sub