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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing Reports With VBA

Status
Not open for further replies.

natatbh

Programmer
Dec 18, 2002
81
US
I want to print a report using vba code. Thing is, I don't want to print it to a printer. I want to print it to a file the same way it is done when you manually click 'print' on the menu and then choose 'print to a file'. I want to do this using vba code and not manually.

Thanks,
natatbh
 
have you tried anything yet or checked HELP?
the simplest way is to put a button on a form, following the Wizard choose Print a Report To File. if you dont want to hit a button on a form to launch your process, you can always look at the code behind the button's OnClick event and use that to write you own module.

g
 
Thanks evilmousse

I want to print it as a post script (.ps) file.
When I select a form and click print, a dialog box comes up. One of the choices is 'print to a file'. When I select this a Post Script file is printed without any prompt asking me with which format I whould like to print my report in. I whould like to do the same with vba code. I want this to be done without any interaction from a user at all.

Thanks,
 
step 1, get ghostscript.

this will (so i'm told, i'm not going to test
this all out myself, honestly) set up a facsimilie
printer much like adobepdfwriter does.

Then, in the code for the dialog form's buttonclick
you'll set the printer as such, something along
the lines of:
Set Application.Printer = Printers("Ghostscript Writer")

I don't know the ghostscript writer at all, but
I imagine it behaves like pdfwriter in that you must
set a few registry keys to specify the output file.

i wrote a faq that might help to that end
faq703-3719

you've got your work cut out for you here.

-g
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top