PDFCreator die xte...........
02.02.2008 18:59:00
Sonnenpeter
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