Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Default Printer not available
Message
From
26/03/2002 01:07:43
 
 
To
21/03/2002 16:45:36
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00635744
Message ID:
00637111
Views:
18
>How would I make certain that the default printer is available. If I only have
>a network printer and I'm not on or the network is down, the following code gives me an error 1958:
>report form (pcControlFile) &pcRange to printer noconsole

You might try playing with my DIRPRTCLASS; once you obtain the name of the default printer, you could do something like:
* Sometime before you need to check
SET PROCEDURE TO DIRPRTCLASS ADDITIVE
oDirPrt = CREATEOBJECT('DirectPrintOutput')

* Whenever you need to check printer availability to accept spooled output

lPrinterCanBeAccessed = .F.
IF oDirPrt.PrinterOpen(cWindowsPrinterName_or_PrintPort_or_PrinterUNC)
   lPrinterCanBeAccessed = oDirPrt.DocOpen()
   oDirPrt.PrinterClose()
ENDIF

* lPrinterCanBeAccessed indicates whether you can successfully create
* spool jobs for the selected printer.  It does not indicate that the 
* printer is currently working (it might have a printer jam or be in use
* by another user's print job) but does report if you can spool output to
* it - if it's busy or out of paper or whatever, Windows will accept any
* work sent to it and hold it (spool the output) until it becomes available
* without giving an error. It will not force a page feed or reset the printer
* state or do any of the other things that writing to the GDI might do. It
* also will not affect any VFP printer job currently in progress, even if
* you're in the middle of writing to that exact printer with VFP
You can download this from the Files section - you'll also need ClsHeap, so download files #986 and #1498
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