Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using VFP (or Win32API) to set the default printer
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01143034
Message ID:
01143041
Views:
11
DECLARE INTEGER SetDefaultPrinter IN winspool.drv; 
    STRING pszPrinter
Will change you Windows default printer.


>I am attempting to change the default printer, print, then change it back (without displaying any dialogs, etc).
>
>Assuming MytempPrinter is the name of the installed printer I want to print to, this is easy to do in VFP using:
>
>
>* Change to the printer I need to print to
>Set Printer to Name "MytempPrinter"
>
>* execute code that prints, etc.
>
>* Change back to the default printer
>Set Printer to Default
>
>
>However, the code above will only affect printing from VFP. Since I am using automation to control Excel and calling the printing from Excel (not VFP), my output is routed to the Windows default printer, not the printer I set to in VFP.
>
>Does anyone have sample code (using WIN32 API, etc) that will allow me to silently get the name of the current Windows default printer, change the Windows default printer to another printer, then change it back to the original?
>
>Thanks,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform