How to create a PDF document with VBA?

T

Tom

Hello

I'd like to create PDF documents with VBA. For this I downloaded the PDF995
writer. I created the following macro:

Sub Print_PDF()
ActiveSheet.PrintOut _
ActivePrinter:="PDF995 on Ne03:", _
PrintToFile:=True, _
PrToFilename:="C:\Temp\Test.pdf"
End Sub

The pdf file was created but I'm not able to open it with the Adobe Acrobat
Reader. The error message 'unknown format' appears. What am I doing wromg?

Tom
 
B

Bill Simot

Tom said:
Hello

I'd like to create PDF documents with VBA. For this I downloaded the PDF995
writer. I created the following macro:

Sub Print_PDF()
ActiveSheet.PrintOut _
ActivePrinter:="PDF995 on Ne03:", _
PrintToFile:=True, _
PrToFilename:="C:\Temp\Test.pdf"
End Sub

The pdf file was created but I'm not able to open it with the Adobe Acrobat
Reader. The error message 'unknown format' appears. What am I doing wromg?

Tom
From what I recall of using PDF995 with Access, you can control the
file name and location that PDF995 saves to with an .ini file. If
something isn't specified in the .ini file, PDF995 will ask for a file
name and location. This was a year or two ago so my memory may be a bit
off.

My guess is that the PDF file that PDF995 is generating is being
wrapped in a printer file by Excel. I don't think you need to tell
Excel to print this to a file or where to save it. The PDF995 driver
should do that based on the contents of the .ini file. Just tell Excel
to print the file using the PDF995 printer.

You should be able to verify this if you open the file you curretly
have in notepad or other text editor and look at the first line. If it
is a valid PDF file, it will start with '%PDF' followed by the version.

Bill
 

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