Domski
Well-known Member
- Joined
- Jan 18, 2005
- Messages
- 7,292
Hi,
I've been working on this problem on and off for a number of months now and have just about got it sussed so thought I'd share it with you as it has mostly been down to postings on this board that I've got it in the end.
Thanks especially to 'biggoan' for his post: http://www.mrexcel.com/board2/viewtopic.php?t=199136&highlight=
Anyway, this seems to avoid the need for a class module but does need you to install the Acrobat Distiller object references in Tools...References in the VBA editor.
You also need to go into the printer properties of the your Adobe PDF 'Printer' and under Printing Preferences...Adobe PDF Settings deselect the Do not send fonts to "Adobe PDF" option. Why, who knows!
Not sure why the macro creates a log file but if you know more about VBA then you probably would.
Hope it helps someone else as it's going to save me a heap loads of time.
I've been working on this problem on and off for a number of months now and have just about got it sussed so thought I'd share it with you as it has mostly been down to postings on this board that I've got it in the end.
Thanks especially to 'biggoan' for his post: http://www.mrexcel.com/board2/viewtopic.php?t=199136&highlight=
Anyway, this seems to avoid the need for a class module but does need you to install the Acrobat Distiller object references in Tools...References in the VBA editor.
You also need to go into the printer properties of the your Adobe PDF 'Printer' and under Printing Preferences...Adobe PDF Settings deselect the Do not send fonts to "Adobe PDF" option. Why, who knows!
Code:
Private Sub Create_PDF()
'Created by Dom Hill with considerable asistance from Biggoan and Mr Excel
Dim tempPDFFileName As String
Dim tempPSFileName As String
Dim tempPDFRawFileName As String
Dim tempLogFileName As String
Sheets("Sales Data").Activate
tempPDFRawFileName = "C:\" & Range("A1").Value
'Define the postscript and .pdf file names.
tempPSFileName = tempPDFRawFileName & ".ps"
tempPDFFileName = tempPDFRawFileName & ".pdf"
tempLogFileName = tempPDFRawFileName & ".log"
' Print the Excel range to the postscript file
ActiveSheet.PrintOut Copies:=1, preview:=False, ActivePrinter:="Adobe PDF", printtofile:=True, Collate:=True, prtofilename:=tempPSFileName
'Create PDF File
Dim myPDFDist As New PdfDistiller
myPDFDist.FileToPDF tempPSFileName, tempPDFFileName, tempShowWindow
'Delete PS File
Kill tempPSFileName
Kill tempLogFileName
End Sub
Not sure why the macro creates a log file but if you know more about VBA then you probably would.
Hope it helps someone else as it's going to save me a heap loads of time.