S
sresnick
My vba code is triggered from within Access. It needs to take an
existing Excel file and convert the first sheet to a .pdf. The only way
I've found to make this work is to have the user manually change the
defaults on Adobe PDF. (From the START button, Settings, Printers, then
right-click on Adobe PDF, Printing Preferences..., Adobe PDF Setting,
then uncheck the box "Do not send fonts to Adobe PDF")
Then, the following code will work:
Sub generatePDF()
Dim xlAppRpt As Excel.Application
Dim wbRpt As Excel.Workbook
Dim wsRpt As Excel.Worksheet
Dim ps2pdf As PdfDistiller
Dim saveFilePS As String, saveFilePDF As String
Dim saveFileLog As String
Set xlAppRpt = New Excel.Application
Set ps2pdf = New PdfDistiller
Set wbRpt = xlAppRpt.Workbooks.Open("D:\Test\SourceExcelFile.xls")
Set wsRpt = wbRpt.Sheets("Sheet1")
saveFilePS = "D:\Test\TempPostScriptFile.ps"
saveFilePDF = "D:\Test\GeneratedPDFfile.pdf"
saveFileLog = "D:\Test\GeneratedPDFfile.log"
If Dir(saveFilePS) <> "" Then Kill (saveFilePS)
wsRpt.PrintOut ActivePrinter:="Adobe PDF", printtofile:=True, _
prtofilename:=saveFilePS
ps2pdf.FileToPDF saveFilePS, saveFilePDF, ""
If Dir(saveFilePS) <> "" Then Kill saveFilePS
If Dir(saveFileLog) <> "" Then Kill saveFileLog
wbRpt.Close False
xlAppRpt.Quit
ps2pdf.canceljob
Set xlAppRpt = Nothing
Set wbRpt = Nothing
Set wsRpt = Nothing
Set ps2pdf = Nothing
End Sub
Is there a better way to do this? Is there a way to do this without
having to change the Adobe "Printer preferences," or to do so
programatically without great headaches?
Thanks,
Stuart
http://home.comcast.net/~sresnick2/mypage.htm
existing Excel file and convert the first sheet to a .pdf. The only way
I've found to make this work is to have the user manually change the
defaults on Adobe PDF. (From the START button, Settings, Printers, then
right-click on Adobe PDF, Printing Preferences..., Adobe PDF Setting,
then uncheck the box "Do not send fonts to Adobe PDF")
Then, the following code will work:
Sub generatePDF()
Dim xlAppRpt As Excel.Application
Dim wbRpt As Excel.Workbook
Dim wsRpt As Excel.Worksheet
Dim ps2pdf As PdfDistiller
Dim saveFilePS As String, saveFilePDF As String
Dim saveFileLog As String
Set xlAppRpt = New Excel.Application
Set ps2pdf = New PdfDistiller
Set wbRpt = xlAppRpt.Workbooks.Open("D:\Test\SourceExcelFile.xls")
Set wsRpt = wbRpt.Sheets("Sheet1")
saveFilePS = "D:\Test\TempPostScriptFile.ps"
saveFilePDF = "D:\Test\GeneratedPDFfile.pdf"
saveFileLog = "D:\Test\GeneratedPDFfile.log"
If Dir(saveFilePS) <> "" Then Kill (saveFilePS)
wsRpt.PrintOut ActivePrinter:="Adobe PDF", printtofile:=True, _
prtofilename:=saveFilePS
ps2pdf.FileToPDF saveFilePS, saveFilePDF, ""
If Dir(saveFilePS) <> "" Then Kill saveFilePS
If Dir(saveFileLog) <> "" Then Kill saveFileLog
wbRpt.Close False
xlAppRpt.Quit
ps2pdf.canceljob
Set xlAppRpt = Nothing
Set wbRpt = Nothing
Set wsRpt = Nothing
Set ps2pdf = Nothing
End Sub
Is there a better way to do this? Is there a way to do this without
having to change the Adobe "Printer preferences," or to do so
programatically without great headaches?
Thanks,
Stuart
http://home.comcast.net/~sresnick2/mypage.htm