Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
944to948
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
944to948
944to948
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

PDFCreator die xte...........

PDFCreator die xte...........
02.02.2008 18:59:00
Sonnenpeter
Hallo,
nachdem mir Sepp den Link www.excelguru gezeigt hat bin ich am probieren mannomann
Nachfolgend im Makro "mein Problem" da sich Excel immer wieder aufhängt und ich nicht mehr weiter weiss.
Option Explicit

Sub PrintToPDF_Early()
'Author       : Ken Puls (www.excelguru.ca)
'Macro Purpose: Print to PDF file using PDFCreator
' (Download from http://sourceforge.net/  _
_
projects/pdfcreator/)
'   Designed for early bind, set reference to PDFCreator
Dim pdfjob As PDFCreator.clsPDFCreator
Dim sPDFName As String
Dim sPDFPath As String
Dim Arbeiten As String
Dim StandartDrucker As String
StandartDrucker = Application.ActivePrinter
Arbeiten = Sheets("Datenblatt").Range("C9").Value
Sheets("Abfrage").Select
'/// Change the output file name here! ///
sPDFName =  Arbeiten & ".pdf"
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.", 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
ActiveSheet.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
mein Problem
'Wenn ich mit F8 durchmarschiere funzt das Makro dauert aber bei DoEvents immer so 30 Sekunden  _
bis es weitergeht.
'Wenn ich das Makro mit F5 durchlaufen lasse hängt sich Excel immer auf. Ich komme nur über  _
Task beenden weiter. Längste Zeit die ich das Makro ohne Task beenden laufen lies 25 Minuten.
'Wait until PDF creator is finished then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
 DoEvents
Loop
pdfjob.cClose
Set pdfjob = Nothing
Application.ActivePrinter = StandartDrucker
End Sub
Oh Mann oh Mann
Gruß Sonnenpeter

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: PDFCreator die xte...........
02.02.2008 20:17:27
Josef
Hallo Peter,
ohne es testen zu können, (ich habe PDFVreator nicht installiert), probier es mal mit einer kleinen Pause im Loop.
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************

Option Explicit

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub PrintToPDF_Early()
'Author : Ken Puls (www.excelguru.ca)
'Macro Purpose: Print to PDF file using PDFCreator
' (Download from http://sourceforge.net/ _
    projects/pdfcreator/)


' Designed for early bind, set reference to PDFCreator

Dim pdfjob As PDFCreator.clsPDFCreator
Dim sPDFName As String
Dim sPDFPath As String
Dim Arbeiten As String
Dim StandartDrucker As String

StandartDrucker = Application.ActivePrinter

Arbeiten = Sheets("Datenblatt").Range("C9").Value
Sheets("Abfrage").Select

'/// Change the output file name here! ///
sPDFName = Arbeiten & ".pdf"
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.", 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
ActiveSheet.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
    Sleep 250
Loop


pdfjob.cClose
Set pdfjob = Nothing
Application.ActivePrinter = StandartDrucker
End Sub


Gruß Sepp



Anzeige
Die Pause hilft..........................
02.02.2008 20:32:00
Sonnenpeter
Hallo Sepp,
die Pause hilft :-)
Das Makro läuft jetzt durch.
Herzlichen Dank!
Gruß Peter

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige