VB Code to print to .pdf

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to print the file to .pdf, but am not sure how to code the VB to do
it. Right now the print is going to the default printer; I need to change the
printer that it prints to.
 
Hi Doug,
I feel like your new best friend (or that crazy person who asks too many
questions - you decide).

I actually have PrimoPDF on my computer already, and I love it - very easy
to use. I can select "Print" from the file menu and change the printer, but
I'd rather have a button on my form that allows users to print a copy of the
report directly to .pdf format (a shortcut). Currently my VB looks like:

Dim stDocName As String
Dim MyForm As Form

stDocName = "frmMVR"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False

Where in here can I set the printer type? I want it to select the printer
PrimoPDF.
 
Hi Jennifer,

You might find that one of these methods works for you. You may need to add
a command button to your form to print a report based on the active record in
your form, instead of the form itself.

Printer Selection Utility
http://allenbrowne.com/AppPrintMgt.html

How to automate the process of selecting the printer
for a report in Microsoft Access
http://support.microsoft.com/?id=319317

Programming Printer Settings in Microsoft Access 2002

http://msdn.microsoft.com/library/d...ry/en-us/dnacc2k2/html/odc_acc10_printers.asp


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
Jennifer,

An alternative approach is to open the report in design view, go to the
File|Page Setup menu, on the 'Page' tab select the 'Use specific
printer' option, and then enter your PrimoPDF in there. I think that's
how I would do it.
 
Jennifer, the below code works for me. You don't have to mess around with
changing the default printer and then changing it back again. The code
changes the target printer for this report this time. Works for any report,
any printer (Not tested for networked printers). Access 2003.
HTH, UpRider

DoCmd.OpenReport "YourReportName", acViewPreview
Application.Reports("YourReportName").Printer =
Application.Printers("YourPDFPrinter")
 
Would the name of the printer be the name I see when I select the dropdown or
is there another "name" that is recoginized by the computer?
 
Yes, it's the printer name that you see in the Windows print dialog
dropdowns...

UpRider
 
It should be the same

Pieter

Jennifer Cali said:
Would the name of the printer be the name I see when I select the dropdown
or
is there another "name" that is recoginized by the computer?



--
 

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