Hallo,
ich habe ein etwas dubioses Problem mit einem Excel-Makro.
Das Makro (unten anbei) gibt alle Arbeitsblätter einer Excel-Datei als PDF aus. Bei mir auf dem Rechner funktioniert das auch ganz gut, das Programm läuft fehlerfrei durch. Ich habe WIN XP sowie MS Office 2007 installiert. Vor Ausführung des Makros habe ich im VBA-Editor unter Verweise PDFCreator.exe eingebunden.
Jedoch läuft das Makro bei den Kollegen auf einen Fehler. Das Makro bricht stets an folgender Stelle ab:
Set pdfjob = New PDFCreator.clsPDFCreator
Die Meldung besagt, dass das Objekt nicht bekannt ist obwohl der Verweis korrekt gesetzt zu sein scheint. Die Installationsumgebung der PCs, auf denen das Makro nicht funktioniert, ist genau identisch. WIN XP mit MS Office 2007.
Kann mir jemand weiterhelfen, irgendeine Idee, warum das Programm abbricht? Liegt es evtl. an der Creator-Version?
Herzlichen Dank für die Hilfe,
Christoph
Public Sub Print2Pdf_modifiziert(oPrintRange As range, sPDFName As String)
Dim pdfjob As PDFCreator.clsPDFCreator
Dim sPDFPath As String
'/// hier output pfad ///
sPDFPath = ActiveWorkbook.Path & Application.PathSeparator
'Check if worksheet is empty and exit if so
If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub
Set pdfjob = New PDFCreator.clsPDFCreator
With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator. Please kill the running PDFCreator processes.", vbCritical + _
vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With
'Print the document to PDF
oPrintRange.PrintOut copies:=1, ActivePrinter:="PDFCreator"
'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
'Wait until PDF creator is finished then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
'Wait until the PDF file shows up then release the objects
'Do Until Dir(sPDFPath & sPDFName) <> ""
'DoEvents
'Loop
Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) + 1)
pdfjob.cClose
Set pdfjob = Nothing
End Sub