LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default issues with getting .pdfs to be created

I've tried a number of ways to get my VBA code to create and save pdf
files from excel. I've used a number of different code scraps from
this group and others, and the only thing that works on my system
(Excel 2003 running on Windows XP) is the following - with caveats:

The issue is that when I launch the code, it won't run if the Adobe
setup box "Rely on system fonts only" is checked. If I uncheck the box
manually, the code works fine. The issue is that for my users to
manually go into the Print menu and change the preferences each time
they run the code the first time is impractical. Once the box has been
unchecked, there's no issue as long as the application stays open.

Interestingly, using the normal method of creating a pdf from Excel
(launching from the toolbar button in Excel) the checked box is the
default setting and everything runs fine.

So,....any suggestions?

Art

code follows:

Sub Print_PDF()

'need to check Reference to Acrobat Distiller in Tools --
References
' ensure "Rely on system fonts only..." box is unchecked on page
setup
'Define the postscript and .pdf file names.

Dim PSFileName As String
Dim PDFFileName As String
Dim lclFileName As String

lclFileName = Cells(1, 1) ' filename is contained in first
cell

PSFileName = "D:\My Documents\" & lclFileName & ".ps"
PDFFileName = "D:\My Documents\" & lclFileName & ".pdf"
'Print the Excel range to the postscript file

'was originally ActivePrinter = "Adobe PDF"

ActiveWindow.SelectedSheets.PrintOut copies:=1, preview:=False,
ActivePrinter:="Adobe PDF on Ne01:", _
printtofile:=True, collate:=True, prtofilename:=PSFileName


'Convert the postscript file to .pdf
Dim myPDF As PdfDistiller
Set myPDF = New PdfDistiller
myPDF.FileToPDF PSFileName, PDFFileName, ""

Kill "D:\My Documents\" & lclFileName & ".ps"
Kill "D:\My Documents\" & lclFileName & ".log"

End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining PDFs RJ Excel Programming 0 December 31st 08 03:39 PM
Controling Acrobat PDFs YS Excel Discussion (Misc queries) 1 December 18th 04 10:47 AM
Controling Acrobat PDFs No Name Excel Programming 0 December 17th 04 04:41 PM
Creating PDFs from Excel VBA KarimK Excel Programming 0 October 5th 04 03:04 PM
Opening PDFs from VBA?? Eugene[_7_] Excel Programming 3 July 2nd 04 10:32 AM


All times are GMT +1. The time now is 02:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"