Link to home
Start Free TrialLog in
Avatar of GaryHoff
GaryHoff

asked on

can't reference the Printer and Printers Object

I am using Access 2000, and trying to change the printer for a report.
"Dim X As Printer" will not compile - doesn't accept Printer or Printers as an object type.
Examples that I have seen use these object types to querry the printers list.

What should I do to get this to work?

Avatar of pradapkumar
pradapkumar

u can use Common DIalog control to show available printers and let the users to select one among them.
Avatar of GaryHoff

ASKER

The custiomer wants to use a specific printer that varies by user.  They do not want a pop up dialog box.
then u can use printer object directly which will prints output 2 default printer assigned to that client system.
They don't want to change the default printer for the other applications.
This printer's settings is for a printer+paper tray that has letterhead so they don't want to make it the default.
Plus, this application is used by multiple users, and due to OS differences the printers have different names so just one setting doesn't work.
I want to be able to set the printer to "HP Laser" for computer "FRONT DESK" and "Cannon" for computer "BACK OFFICE".
please read the following links

https://www.experts-exchange.com/questions/10204395/default-printer.html?query="default+printer"&topics=93


https://www.experts-exchange.com/questions/10338782/Default-Printer.html?query="default+printer"&topics=93

https://www.experts-exchange.com/questions/20190556/Default-Printer.html?query="default+printer"&topics=93

in addition what my suggestion is

try to store the printer assigned before ur printing starts to ur designated printer in a seperate variable.
then change the current printer by codeing for that purpose the above links will help you.
after successful completion of ur printing process just re assign the old one from the variable.

i hope this will help to you.
Your examples get back to my original problem:

"Dim X As Printer" will not compile.
What do I need to do to get "Printer" to be reconized as an object?
you can save the old printers name with

    strTemp = Printer.DeviceName
    MsgBox strTemp

after completed ur printing with ur newly selected printer u can restore to old one with the following code

  'Set the Printer object to the selected device
  Dim prtSelected As Printer
  For Each prtSelected In Printers
    If prtSelected.DeviceName = strTemp Then
      Set Printer = prtSelected
      Exit For
    End If
  Next


the above code will help u.
you are missing the problem completely!!!!

I cannot run the above code because:

"Dim prtSelected As Printer"

will not compile.  Why is "Printer" not reconized as a valid Object?
 
ASKER CERTIFIED SOLUTION
Avatar of pradapkumar
pradapkumar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
After much pain, time and trouble, I cleared everything, reinstalled the OS, Access, and the above works.
Thanks.