AW: Automatisierung mehrerer Tabellen in PDF
Tobias
Hallo 13Chris,
Zuerst Brauchst Du den Adobe Distiller, wenn Du den hast musst Du die Referenz
für den Distiller setzten.
Hier der Code:
Sub RegisterDLL()
Dim lngCounter As Long
Dim objPDF As Object
Dim bolDLLInstalled As Boolean
bolDLLInstalled = False
With ThisWorkbook.VBProject.References
For lngCounter = 1 To .Count
If .Item(lngCounter).Name = "ACRODISTXLib" Then
bolDLLInstalled = True
End If
Next lngCounter
If bolDLLInstalled = False Then
Set objPDF = .AddFromGuid(strDistillerGUID, 1, 0)
End If
End With
Set objPDF = Nothing
End Sub
Es ist einfacher wenn alle Reports in einem Workbook drin sind.
Selektiere alle Reports die Du in deinem PDF haben möchtes und führe folgenden Code aus.
Sub PrintToPDF(strFileName As String, strOriginPath As String, strTargetPath As String)
Dim objDistiller As New ACRODISTXLib.PdfDistiller
objDistiller.bShowWindow = False
ActiveWindow.SelectedSheets.PrintOut , printtofile:=True, _
collate:=True, prtofilename:=strOriginPath & strFileName & ".ps"
objDistiller.FileToPDF strOriginPath & strFileName & ".ps", strTargetPath & strFileName & ".pdf", ""
Kill strOriginPath & strFileName & ".ps"
Set objDistiller = Nothing
End Sub
Sub Printing()
Call PrintToPDF("test", "C:\Excel\", "E:\PDF\")
End Sub
Hoffe das bringt Dich weiter...
Gruss
Tobias