Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Report Problem
Message
 
 
To
13/11/2002 09:31:11
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Title:
Miscellaneous
Thread ID:
00711664
Message ID:
00722100
Views:
13
>Nadya,
>
>Finally solved it. ( I think, no problems reported since a few days now )
>
>Have not tested the 'set printer to default' after having 'set printer to (name)'. Had already implemented the code below. Anyway, the apps use Printer_Set() and Printer_Get() and things can easily be changed if needed in the future.
>
>Should error 1958 reoccur, switch to the code below (wsh code comes from google)
>
>
>&& to change the printer (in addition to clearing expr, tag & tag2 from the reports) I do this
>local sPrint
>=Printer_Set(this.Parent.PrinterList.Value, @sPrint)  && this.Parent.PrinterList.Value : combo box with selected printer
>
>&& print
>
>&& to reset the printer
>=Printer_Set(sPrint)
>
>&& functions
>*-------------------------------------------------------------------------------
>function Printer_Get()
>	return WindowsPrinter_Get()
>endfunc
>*-------------------------------------------------------------------------------
>function Printer_Set(PrinterNew, PrinterOld)
>	=WindowsPrinter_Set(PrinterNew, @PrinterOld)
>endfunc
>*-------------------------------------------------------------------------------
>function	WindowsPrinter_Get()
>	return set('Printer', 2)
>endfunc
>*-------------------------------------------------------------------------------
>function	WindowsPrinter_Set(PrinterNew, PrinterOld)
>	
>	local wsh, sError
>	sError = on('error')
>	PrinterOld = WindowsPrinter_Get()
>	do case
>	case lower(PrinterOld) <> lower(PrinterNew)
>		wsh = CreateObject('WScript.Network')
>		private HadError
>		HadError = FALSE
>		on error HadError = TRUE
>		wsh.SetDefaultPrinter(PrinterNew)
>		on error &sError
>		wsh = Null
>		return !HadError
>	endcase
>endfunc
>*-------------------------------------------------------------------------------
>
Thanks a lot for sharing this, it may help me as well, if similar problem occurs.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform