Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Print To pdf Not Working

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Print To pdf Not Working

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

"jutlaux" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Print To pdf Not Working

2003

"Barb Reinhardt" wrote:

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

"jutlaux" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Print To pdf Not Working

You may find something here that's helpful.

http://www.rondebruin.nl/pdf.htm

"jutlaux" wrote:

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Print To pdf Not Working

Unfortunately I am not using 2007 so the add-in and code will not work.

"Barb Reinhardt" wrote:

You may find something here that's helpful.

http://www.rondebruin.nl/pdf.htm

"jutlaux" wrote:

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
sm sm is offline
external usenet poster
 
Posts: 13
Default Print To pdf Not Working

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.

"jutlaux" wrote:

Unfortunately I am not using 2007 so the add-in and code will not work.

"Barb Reinhardt" wrote:

You may find something here that's helpful.

http://www.rondebruin.nl/pdf.htm

"jutlaux" wrote:

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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Print To pdf Not Working

I also face the same problem with WORD.
The solution I found is to use the FREE PDF Printer (http://www.bullzip.com)


This printer allows to define the name of the PDF file you want to generate.


url:http://www.ureader.com/msg/103768455.aspx
Reply
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
Print Fit To Not Working jutlaux Excel Discussion (Misc queries) 1 August 27th 08 09:42 PM
Disable print not working [email protected] Excel Programming 2 September 26th 06 04:14 AM
Print Code not working Sheeny[_27_] Excel Programming 1 May 9th 06 03:30 PM
Printer.Print Not Working? pike168 Excel Programming 5 April 2nd 06 02:59 PM
before print event not working goss[_17_] Excel Programming 2 January 29th 04 03:54 AM


All times are GMT +1. The time now is 11:50 AM.

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

About Us

"It's about Microsoft Excel"