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?
"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?
u can use Common DIalog control to show available printers and let the users to select one among them.
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.
ASKER
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".
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.
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.
ASKER
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?
"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.
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.
ASKER
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
After much pain, time and trouble, I cleared everything, reinstalled the OS, Access, and the above works.
Thanks.
Thanks.