ich habe hier eine Tabelle, in der wöchentlich ein Bereitschaftsplan erstellt wird. Dieser wird dann hiermit
Sub PrintToPDF()
Dim pdfjob As Object
Dim sPDFName As String
Dim sPDFPath As String
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
sPDFPath = "D:\Ruf"
If pdfjob.cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + _
vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
With pdfjob
sPDFName = "Ruf" & Range("D169").Text & "-" & Range("F169").Text & ".pdf"
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0
.cClearCache
End With
ActiveWorkbook.PrintOut Copies:=1, Collate:=True, ActivePrinter:="Erstelle PDF _
auf Ne04:"
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
pdfjob.cClose
Set pdfjob = Nothing
End Sub
automatisch als pdf ausgedruckt. Das funktioniert soweit auch hervorragend. Der Dateiname wird automatisch vergeben (Datum des Beginns und Ende). Folgendes Problem:Wenn ich jetzt eine Zeile einfüge, verschieben sich die Zellen, aus denen der Dateiname erstellt wird. Als Dateiname bekomme ich dementsprechend - nix :-)
Hab schon probiert in der Zeile
sPDFName = "Ruf" & Range("D169").Text & "-" & Range("F169").Text & ".pdf"
mit Cells statt Range zu arbeiten, ich kriegs trotzdem nicht hin.
Wer weiß Rat?
Danke schonmal
Uwe