AW: PDF per Knopfdruck speichern
Josef
Hallo Nico,
Verweis setzen, Code anpassen und probieren.
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************
Option Explicit
Private Function PrintToPDF(objSheet As Worksheet, strFileName As String, strPath As String)
'Benötigt den Verweis auf "Acrobat Distiller"!
Dim objDistiller As New ACRODISTXLib.PdfDistiller
objDistiller.bShowWindow = False
objSheet.PrintOut PrintTofile:=True, _
PrtoFilename:=strPath & strFileName & ".ps"
objDistiller.FileToPDF strPath & strFileName & ".ps", _
strPath & strFileName & ".pdf", ""
Kill strPath & strFileName & ".ps"
Set objDistiller = Nothing
End Function
Sub printPDF()
Dim objSh As Worksheet
Dim strPath As String, strFileName As String, strActPrinter As String
Set objSh = Sheets("Tabelle1") 'Tabellenname anpassen!
With objSh
strPath = .Range("A1").Text
If Right(strPath, 1) <> "\" Then strPath = strPath & "\"
strFileName = .Range("C3").Text 'Zelladresse mit dem Namen - Anpassen!
strFileName = strFileName & ".pdf"
End With
strActPrinter = Application.ActivePrinter
Application.ActivePrinter = "Adobe PDF auf Ne03:" 'den Druckernamen anpassen, du
'ermittelst ihn, wenn du ein Makro aufzeichnest und den
'Drucker auswählst!
PrintToPDF objSh, strFileName, strPath
Application.ActivePrinter = strActPrinter
Set objSh = Nothing
End Sub
Gruß Sepp