pdfDist.FileToPDF does nothing

B

barbetta3141

Hello,

I'm trying to automate the creation of pdf files. I posted my code
below. The line I'm having problems with is

pdfDist.FileToPDF "c:\My Documents\testExcelToPDF.PS", "c:\My
Documents\testExcelToPDF.pdf", ""

The code runs without causing any errors, but the Adobe code doesn't
seem to work. I can see the .ps file being created, but when I step
through the FileToPDF line, nothing happens (no pdf is created, but no
error either). I'm using Excel 2003 with Acrobat 7.0 Professional and
Distiller 7.0. Thanks for your help.


Public Sub PostProblemOnNewsgroup()
Dim pdfDist As New ACRODISTXLib.PdfDistiller
Dim pdfPrinter, pdfName
Dim strFileName As String

Set fs = CreateObject("Scripting.FileSystemObject")

strFileName = "testExcelToPDF.ps"
Application.ActivePrinter = "Adobe PDF on Ne02:"

ActiveWindow.SelectedSheets.PrintOut Copies:=1, preview:=False, _
ActivePrinter:="Adobe PDF on Ne02:", printtofile:=True, _
collate:=True, PrToFileName:=strFileName

pdfDist.FileToPDF "c:\My Documents\testExcelToPDF.PS", "c:\My
Documents\testExcelToPDF.pdf", ""
Set pdfDist = Nothing
fs.DeleteFile pdfFilePath & "*.PS"
End Sub
 
S

SA

Running the distiller com object does require administrator privileges on
your machine. That may be an issue.

If you want a relatively easy way to output a worksheet or whole workbook to
a PDF file using VBA and Acrobat 7, you might want to look at our XL PDF
Wizard Add In. You can not only automate creation of XL based PDFs but also
merge in Word docs and external PDF files and bookmark the whole thing using
code. You'll find it in the developer tools section of our web.

Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top