OS dependant code

R

RipperT

I have code in a form button that prints a report to a specific printer:

Dim stDocName As String
Dim strDefaultPrinter As String
'Get default printer
strDefaultPrinter = Application.Printer.DeviceName
'Change to secondary printer
Set Application.Printer = Application.Printers("HP LaserJet 9050 PCL6")
'Print document
stDocName = "rpt1FormalAW"
DoCmd.OpenReport stDocName, acNormal
'Switch back to default printer
Set Application.Printer = Application.Printers(strDefaultPrinter)

My problem is that "HP LaserJet 9050 PCL6" is only good for NT machines. The
XP driver for the same printer is "HP LaserJet 9050 PCL 6", so I get errors
on XP machines. Is there an OS class I can use thus (pseudo):

If OS = (NT) Then
use this printer
Else if OS = (XP) Then
use this printer
End if

Thanx,

Ripper
 
M

Marshall Barton

RipperT said:
I have code in a form button that prints a report to a specific printer:

Dim stDocName As String
Dim strDefaultPrinter As String
'Get default printer
strDefaultPrinter = Application.Printer.DeviceName
'Change to secondary printer
Set Application.Printer = Application.Printers("HP LaserJet 9050 PCL6")
'Print document
stDocName = "rpt1FormalAW"
DoCmd.OpenReport stDocName, acNormal
'Switch back to default printer
Set Application.Printer = Application.Printers(strDefaultPrinter)

My problem is that "HP LaserJet 9050 PCL6" is only good for NT machines. The
XP driver for the same printer is "HP LaserJet 9050 PCL 6", so I get errors
on XP machines. Is there an OS class I can use thus (pseudo):

If OS = (NT) Then
use this printer
Else if OS = (XP) Then
use this printer
End if


AFAIK, you need to use something like thisL
http://www.mvps.org/access/api/api0055.htm
 

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

Similar Threads


Top