Print To pdf Not Working

J

jutlaux

I am trying to print a excel worksheet to a pdf file. Here is the code:

Sub SaveAsPDF ()

ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"CutePDF Writer on CPW2:", PrintToFile:=True, Collate:=True,
PrToFileName:="C:\WeeklyDTReport.pdf"

End Sub

Everything seems to be working correctly due to the fact that I do get the
..pdf file at the correct location with the correct name. The problem I have
is when I go to open the file using Adobe Reader I get the following error:

"Adobe Reader could not open 'WeeklyDTReport.pdf' because it is either not a
supported file type or because the file has been damaged (for example, it was
sent as an email attachment and wasn't correctly decoded)."

If I set PrintToFile = False and browse to the path and enter the name when
prompted Adobe opens the file fine.

What am I missing?

Thanks
 
B

Barb Reinhardt

I've seen some saveas code differences between 2003 and 2007 that IIRC have
the same problem. What version of Excel are you using?
 
J

jutlaux

2003

Barb Reinhardt said:
I've seen some saveas code differences between 2003 and 2007 that IIRC have
the same problem. What version of Excel are you using?
 
S

SM

I had a similar issue and we use a product called freeware GhostScript with
word 2003. Ghostscript is installed as a PDF printer driver. You can do a
..PrintOut to this printer to a file that will generate a .PS (postscript)
file. You can then call ps2pdf.bat file supplied by GhostScript from within
word to convert the .PS file to .PDF!!

Hope this helps.
SM.
 

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