Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Default Printer Win2000 vs Vista

Status
Not open for further replies.

JICGreg

Technical User
Mar 14, 2007
34
The following code will work on my windows 2000 machine but not my vista machine:

oNet = createobject("WScript.Network")
oNet.SetDefaultPrinter("Phaser 8400N Color")

When I try to run it on the vista machine I receive the following error "OLE IDispatch exceptio code 0 from WSHNetwork Setdefaultprinter: There is no printer called "Phaser 8400N Color"

If I try this code on the vista machine
*oNet.SetDefaultPrinter("\\servername\Phaser 8400N Color")

the code executes fine but it then does not work on the win2000 machine.

Thanks for any help.
 
How about wrapping the code:

if os(3) >= '6'
oNet.SetDefaultPrinter("\\servername\Phaser 8400N Color")
else
oNet.SetDefaultPrinter("Phaser 8400N Color")
endif

Doug
 
Mike Lewis,

Your code doesn't change the default printer.
 
Assuming the requirement is to change the Windows default printer, something like this should work:

Code:
DECLARE Long SetDefaultPrinter ;
  In WINSPOOL.DRV String pPrinter
lcPrinter = GETPRINTER()
IF NOT EMPTY(lcPrinter)
  SetDefaultPrinter(lcPrinter)
ENDIF

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Yes, I thought that the thread originator wanted to change Windows Default printer, not VFP printer. Your last code solves this problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top