Selecting Printers

  • Thread starter Thread starter Glimmer
  • Start date Start date
G

Glimmer

Guest
I have in the past been using a Macro to select and automatically print the results of a query to the default printer.
I now have more than one printer connected to the computer via a network.
Is it possible to select a specific printer via VB so that printouts will automatically go to this printer without further user intervention?
Many thanks to anyone who can spend a moment mulling this one over.
Regards,
Michael.
 
Michael,

This is from another forum (from fancyprarie)

Here's how to change your default printer in Access (Courtesy of "Access 2000 Developer's Handbook Volume 1")

Sub ChangeDefaultPrinterAndPrint()

Dim devs as Devices
Dim dev as Device

'**************************************
'* Set up the collection of devices *
'**************************************

Set devs = New Devices

'*********************************************
'* Store away the current default printer. *
'*********************************************

Set dev = devs.CurrentDevice

'**********************************
'* Change the printer and print *
'**********************************

Set devs.CurrentDevice = devs("HP DeskJet 890C")
Docmd.OpenReport "YourReport"

'**************************************************
'* Set the Default printer back the way it was. *
'* Destroy the Devices object. *
'**************************************************

Set devs.CurrentDevice = dev

Set devs = Nothing
set dev = Nothing

End Sub

hth,
Wayne
 
Wayne:

Always interested in finding new Access forums but have been unable to find a FancyPrairie. Can you post the website address?

Autoeng
 
Autoeng,

FancyPrairie is the person who submitted. The forum is
Tek-Tips.

Wayne
 
I am using this code exactly and Devices and Device are not showing as options to choose from. I get a user type not defined error. Is there some reference i need to include or something?

Dim devs As devices
Dim dev As device



Sean
 
Was this problem ever solved?

I apologise for opening a post thats been closed for so long, however, I am experiencing the exact same problem, I'm using Access 2003, I would very much appreciate it if the answer to this problem could be posted...


Thank you in anticipation
 
Have attached a file containing modules that allow you to select a default printer through code. They are fairly well documented so you shouldn't have too much trouble figuring out how to use them :)

Hope this helps
 

Attachments

Users who are viewing this thread

Back
Top Bottom