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

  • Thread starter Thread starter Prasad Vanka
  • Start date Start date
P

Prasad Vanka

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
 
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
 
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
 
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
 
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
 
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 said:
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
 

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

Back
Top