|
-
Mar 24th, 2006, 02:34 PM
#1
Thread Starter
New Member
choose a specifc printer (pdf) with code
Hi, I would like to know if someone can give me a code (VB or VBA) to use in a MS Access 97 form to print a report to a specific printer. Basically I want to send a report to the pdf printer (to save the document as an Adobe pdf document). I realize I can choose my default printer from the Windows Control Panel, but I was hoping to be able to do this through code and not reset my default printer. Any suggestions? Thanks!
Tom
-
Mar 24th, 2006, 03:02 PM
#2
Re: choose a specifc printer (pdf) with code
This should get you started.
VB Code:
Sub ThomasJoPrinter()
Dim pPrinterCheck As Printer
Dim pCurrent As Printer
Dim bFound As Boolean
'Record the current default printer
Set pCurrent = Application.Printer
'Loop through all printers
'looking for Acrobat Distiller
For Each pPrinterCheck In Application.Printers
If pPrinterCheck.DeviceName = "Acrobat Distiller" Then
'Make Acrobat the default printer
Application.Printer = pPrinterCheck
'record the fact that it was found
bFound = True
Exit For
End If
Next pPrinterCheck
'if Acrobat was found then print to it
If bFound Then
DoCmd.OpenReport "Prod_hier", acViewNormal, "", "", acNormal
'Reset the default printer
Application.Printer = pCurrent
End If
End Sub
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Mar 24th, 2006, 04:02 PM
#3
Thread Starter
New Member
Re: choose a specifc printer (pdf) with code
Thanks, this looked like it should have worked but when I ran it, I got a "compile error", "User-defined, type not defined" on this:
Dim pPrinterCheck As Printer
I assume "Prod_hier" was to be replaced by the actual report name (called "PMIReport"). Is that assumption correct?
DoCmd.OpenReport "Prod_hier", acViewNormal, "", "", acNormal
-
Mar 24th, 2006, 04:28 PM
#4
Re: choose a specifc printer (pdf) with code
Hmmm the printer object is part of the Object Model for Access2003. I can't believe that it wasn't there in 97.
Can you open the Object Browser in the VBEditor (F2) and search for the Printer object?
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Mar 27th, 2006, 08:46 AM
#5
Thread Starter
New Member
Re: choose a specifc printer (pdf) with code
Did a search and got "none found". Only thing even close was:
Access OldConstants A_PRINTALL
ALSO:
acCmdPrint, acCmdPrintPreview, acCmdQuickPrint, acPrintAll
But nothing for a Printer :-(
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|