Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1308to1312
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
Inhaltsverzeichnis

Falsche Farben bei PDF-Export aus Excel

Falsche Farben bei PDF-Export aus Excel
22.04.2013 15:09:50
Thorinson
Hallo,
ich versuche, per VBA mit der PDFCreator-Library Worksheets zu drucken. Das funktioniert auch ganz gut, nur werden hin und wieder bei der Konvertierung (RGB-> CMYK) die Farben nicht übernommen bzw. scheinbar aus der näheren Umgebung angenommen. Linien werden gelb oder blau anstatt schwarz, Felder haben plötzlich eine Hintergrundfarbe und eigentlich rosa Felder sind nun geld genauso wie benachbarte Felder. Die Farbfehler treten nur bei PDFs auf, die mehrere Seiten haben.
Gibt es eine bessere Möglichkeit aus Excel PDFs per VBA zu erzeugen? Oder bessere Einstellungen für den PDFCreator?
Bei der Programmierung habe ich mich stark an den EarlyBinding-Code von Excelguru (Ken Puls) gehalten.
Private Sub PrintToPDF_Early(ByVal printArea As String)
Dim pdfjob As PDFCreator.clsPDFCreator
Dim sPDFName As String
Dim sPDFPath As String
Dim bRestart As Boolean
Dim firstRow As Long, lastRow As Long, prtFirstRow As Long, prtLastRow As Long
Dim i As Integer
firstRow = ActiveSheet.Cells(1, 1).End(xlDown).Row
lastRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
prtFirstRow = 0
prtLastRow = 0
For i = firstRow To lastRow
If Cells(i, 3) = printArea And prtFirstRow = 0 Then
prtFirstRow = i
End If
If Cells(i, 3) = printArea Then
If IsEmpty(Cells(i + 1, 3)) And i  lastRow Then
prtLastRow = i + 3
Else
prtLastRow = i
End If
End If
Next i
MsgBox "Exportiere Bereich '" & printArea & "' (" & "$B$" & prtFirstRow & ":$FF$" &  _
prtLastRow & ") als PDF"
'/// Change the output file name here! ///
ActiveSheet.PageSetup.printArea = "$B$" & prtFirstRow & ":$FF$" & prtLastRow
sPDFName = Format(Date, "YYYYMMDD") & "_-_" & ActiveSheet.Name & "_" & printArea & ". _
pdf"
sPDFPath = ActiveWorkbook.Path & Application.PathSeparator
'Check if worksheet is empty and exit if so
If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub
'Activate error handling and turn off screen updates
On Error GoTo EarlyExit
Application.ScreenUpdating = False
Set pdfjob = New PDFCreator.clsPDFCreator
'Check if PDFCreator is already running and attempt to kill the process if so
Do
bRestart = False
Set pdfjob = New PDFCreator.clsPDFCreator
If pdfjob.cStart("/NoProcessingAtStartup") = False Then
'PDF Creator is already running.  Kill the existing process
Shell "taskkill /f /im PDFCreator.exe", vbHide
DoEvents
Set pdfjob = Nothing
bRestart = True
End If
Loop Until bRestart = False
'Assign settings for PDF job
With pdfjob
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0    ' 0 = PDF
.cClearCache
End With
'Delete the PDF if it already exists
If Dir(sPDFPath & sPDFName) = sPDFName Then Kill (sPDFPath & sPDFName)
'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 the file shows up before closing PDF Creator
Do
DoEvents
Loop Until Dir(sPDFPath & sPDFName) = sPDFName
Cleanup:
'Release objects and terminate PDFCreator
Set pdfjob = Nothing
Shell "taskkill /f /im PDFCreator.exe", vbHide
On Error GoTo 0
Application.ScreenUpdating = True
Exit Sub
EarlyExit:
'Inform user of error, and go to cleanup section
MsgBox "There was an error encountered.  PDFCreator has" & vbCrLf & _
"has been terminated.  Please try again.", _
vbCritical + vbOKOnly, "Error"
Resume Cleanup
End Sub

1
Beitrag zum Forumthread
Beitrag zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
Arbeitest du unter Citrix ? (owT)
22.04.2013 15:27:52
EtoPHG

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige