Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending a file name for printer output

Status
Not open for further replies.

softwise

Programmer
Sep 20, 2006
2
US
I need a VBA script to pass the file name path to a printer that is set up as print to a file without the user having to enter this information.
 
Try this out.

returncode=msgbox ("put some paper in the printer",65,"Print start")
if returncode=1 then
Set ss = CreateObject("WScript.Shell")
ss.run "command /c notepad /p c:\rjm\test.rpt ",1,TRUE
msgbox "Print is finished",64,"Print finished"
end if

set ss = nothing


 
Thanks shadowfox33.

I still have one issue. The script executes but still asks for the output file name when printing. Since the printer is 'print to a file', cna I send the file path and name to the printer for no user intervention.

Thanks
 
I have never been able to script the windows printer dialog box with any luck which is what you need to do here to pre-populate those parameters. I have been trying to write a script to turn on and turn off duplexing from a shortcut with no luck. If I run accross something I will let ya know.

 
But the question is never well-posed. I don't think blanket statement like send a file to printer make any concete meaning unless you say what kind of file.

If it is a text file or msword doc file, you can use word.application using its printout method with the parameter printtofile specifying the file name.

If it is xls file, the same kind of method exists and again the file name can be specified. And no popup asking for filename will ever happen.

In any case, too general a question will lose any useful meaning. Maybe "use" is not a question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top