Excel und PDF Creator Version 0.9.? / Automatisierungsmakro bricht ab

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

 

 

 

Nanu, wo ist denn meine Antwort geblieben??? Also nochmal:

Ich habe ein ähnliches, möglicherweise das gleiche Problem. Es liegt an der Prioritäten-Reihenfolge der verwendeten Bibliotheken. Aber selbst wenn die Priotität des Verweises auf den PDFCreator erhöht wird (noch vor OLE Automation), ist das Problem nicht behoben. Dann gibt es wiederum andere Fehler aus der OLE Automation . Aber jetzt wird es richtig skurril: Einmal Mappe speichern, Prio-Reihenfolge wieder auf ursprüngliche Reihenfolge ändern, Mappe speichern und der Fehler ist (vorläufig) weg.

Hallo!

Versucht es mal mit Late-Binding anstelle von Early-Binding, dann könnte ihr auf den Verweis Verzichten.

-------------------------------------------------------------------------

Sub Test()
Dim pdfJob As Object

Set pdfJob= CreateObject("PDFCreator.clsPDFCreator")

' Hier der weitere Code

Set pdfJob = Nothing
End Sub

----------------------------------------------------------------------------

Gruß, René

 

Hallo!

Versucht es mal mit Late-Binding anstelle von Early-Binding, dann könnte ihr auf den Verweis Verzichten.

-------------------------------------------------------------------------

Sub Test()
Dim pdfJob As Object

Set pdfJob= CreateObject("PDFCreator.clsPDFCreator")

' Hier der weitere Code

Set pdfJob = Nothing
End Sub

----------------------------------------------------------------------------

Gruß, René