Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Change Default Printer
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00704393
Message ID:
00704411
Views:
17
>Can anyone tell me how I can change the default printer selection in VFP using Windows API commands? I'm using a 3rd party graphing package (Graphics Server 5.8), and when printing a graph the default printer is always used. I've tried the FoxPro command SET PRINTER TO NAME GETPRINTER( ), but this doesn't seem to send the user-selected printer info when outputing with this graphing package.
>
>So I believe the solution is to programatically change the default to a temporary user selection (using GETPRINTER()) and then resetting back when the printing is completed. I just don't know how to do is. Any suggestions with sample code are welcome.
>

The easiest solution is to use the Windows Script Host's SetDefaultPrinter method:
cCurrentPrinter = SET('PRINTER',2)
oWSHNet = CREATEOBJ('Wscript.Network')
oWSHNet.SetDefaultPrinter("MyWindowsPrinterName")
*
* Do your stuff
*
oWSHNet.SetDefaultPrinter(cCurrentPrinter)
Obviously, you need the WSH version 2.0 or later installed.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform