ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with the PrToFileName parameter when using the Printout method on a worksheet (https://www.excelbanter.com/excel-programming/298165-problem-prtofilename-parameter-when-using-printout-method-worksheet.html)

Prasad Vanka

Problem with the PrToFileName parameter when using the Printout method on a worksheet
 
Hi,

I have the following line of code in my module:
ActiveWindow.SelectedSheets.PrintOut To:=intPageTo ,
PrintToFile:=True, PrToFilename:="Statement For " & Master.UniqueID &
" " & Date

When I am running the code the application hangs.

So I have changed the above to the following:
ActiveWindow.SelectedSheets.PrintOut To:=intPageTo

So now the sheets are printed properly but I can't save the sheet.
Basically I ewant to save this sheet (to another sheet or any file
format) for future reference.

Can someone help me.

Thanks in advance

regards,
Prasad Vanka

Bernie Deitrick

Problem with the PrToFileName parameter when using the Printout method on a worksheet
 
Prasad,

You may be getting an invalid filename due to the Date containing bad
characters in its default conversion to string. Try changing

PrToFilename:="Statement For " & Master.UniqueID & " " & Date
to

PrToFilename:="Statement For " & Master.UniqueID & " " &
Format(Date,"yyyymmdd")

HTH,
Bernie
MS Excel MVP

"Prasad Vanka" wrote in message
om...
Hi,

I have the following line of code in my module:
ActiveWindow.SelectedSheets.PrintOut To:=intPageTo ,
PrintToFile:=True, PrToFilename:="Statement For " & Master.UniqueID &
" " & Date

When I am running the code the application hangs.

So I have changed the above to the following:
ActiveWindow.SelectedSheets.PrintOut To:=intPageTo

So now the sheets are printed properly but I can't save the sheet.
Basically I ewant to save this sheet (to another sheet or any file
format) for future reference.

Can someone help me.

Thanks in advance

regards,
Prasad Vanka




Venkateswara Prasad Vanka

Problem with the PrToFileName parameter when using the Printout method on a worksheet
 
Hi,

Thanks for the answer. I have got one more query. It did save the sheet
but I don't know what type of file was created. When I try to open it I
get an error message, for eg.,

Windows cannot open this file:
File: Statement For UniqueID-70055#Date-20040513

Is there anyway I can specify the file type. If so what types of files I
can save it to?

Thanks in advance.

regards,
Prasad Vanka

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Bernie Deitrick

Problem with the PrToFileName parameter when using the Printout method on a worksheet
 
Prasad,

Try adding the file extension to the print to file name:

PrToFilename:="Statement For " & Master.UniqueID & " " &
Format(Date,"yyyymmdd") & ".prn"

You could also try ".txt" instead of ".prn"

HTH,
Bernie
MS Excel MVP

"Venkateswara Prasad Vanka" wrote in
message ...
Hi,

Thanks for the answer. I have got one more query. It did save the sheet
but I don't know what type of file was created. When I try to open it I
get an error message, for eg.,

Windows cannot open this file:
File: Statement For UniqueID-70055#Date-20040513

Is there anyway I can specify the file type. If so what types of files I
can save it to?

Thanks in advance.

regards,
Prasad Vanka

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Venkateswara Prasad Vanka

Problem with the PrToFileName parameter when using the Printout method on a worksheet
 
Hi,

sorry that's not working. When I am specifying .prn it is saving as
.pr0. I don't know why n is being converted as 0(zero). I don't want the
save as text option as there are some logos on the sheet which cant be
changed. What might be the best option.

Thanks in advance
regards,
Prasad Vanka

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Bernie Deitrick

Problem with the PrToFileName parameter when using the Printout method on a worksheet
 
Prasad,

The default is a .prn, so I don't know why it is not taking it. Try running
the macro without the PrToFilename , and Excel will open a dialog to have
you enter or choose the file name. Then see how the file turns out.

HTH,
Bernie
MS Excel MVP

"Venkateswara Prasad Vanka" wrote in
message ...
Hi,

sorry that's not working. When I am specifying .prn it is saving as
pr0. I don't know why n is being converted as 0(zero). I don't want the
save as text option as there are some logos on the sheet which cant be
changed. What might be the best option.

Thanks in advance
regards,
Prasad Vanka

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Tony Edgecombe

Problem with the PrToFileName parameter when using the Printout method on a worksheet
 
Venkateswara Prasad Vanka wrote in message ...
Hi,

Thanks for the answer. I have got one more query. It did save the sheet
but I don't know what type of file was created. When I try to open it I
get an error message, for eg.,

Windows cannot open this file:
File: Statement For UniqueID-70055#Date-20040513

Is there anyway I can specify the file type. If so what types of files I
can save it to?

Thanks in advance.

regards,
Prasad Vanka


You might want to look at this article for a bit more info on prn file formats.

http://www.frogmorecs.com/arts/what_is_a_prn_file.html

Regards

Tony Edgecombe
www.frogmorecs.com
Software for printing


All times are GMT +1. The time now is 10:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com