Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error loading printer driver
Message
From
25/11/2002 06:51:56
 
 
To
25/11/2002 05:15:15
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00726349
Message ID:
00726365
Views:
28
>Anybody knows how come i got this message ?
>Printers work fine outside the application but i have this message
>when i run a report.
>
>Thank you
Alessio,

I've had that error for a long time. Here's how I got rid of it. There may be other ways

(1) As Gerhard said, first the reports have to be cleaned up. See code below for an example on how to do that.
function	ReportsCleanUp()
	local reports[1], n, s, j, lines, newexpr, t, KeepLine
	
	s = select(0)
	select 0
	
	n = adir(reports, '.\Report\*.??x')
	t = therm(n, 'Cleaning up reports...')
	
	for i = 1 to n
		if( !inlist(justExt(reports[i,1]), 'FRX', 'LBX') )
			loop
		endif
		
		=t.update(i, juststem(reports[i,1]))

		use ('.\' + reports[i,1]) excl
		go top
		locate for	(ObjType = 1) and (ObjCode = 53)
		assert found()

		lines = memlines(expr)
		newexpr = ''
		for j = 1 to lines
		
			do case
			case at('DRIVER=',mline(expr,j)) == 1
				KeepLine = TRUE
			case at('ORIENTATION=',mline(expr,j)) == 1
				KeepLine = TRUE
			case at('PAPERSIZE=',mline(expr,j)) == 1
				KeepLine = TRUE
			case at('COPIES=',mline(expr,j)) == 1
				KeepLine = TRUE
			otherwise
				KeepLine = FALSE
			endcase
		
			do case
			case KeepLine
				newexpr = newexpr + mline(expr,j) + chr(13) + chr(10)
			endcase

			
		endfor
		
		if( empty(at('DRIVER', newexpr) ) )
			newexpr = 'DRIVER=winspool' + chr(13) + chr(10) + newexpr  
		endif
		
		repl expr with newexpr, tag with '', tag2 with ''
		pack
		use
		do case
		case inlist(justExt(reports[i,1]), 'FRX')
			compile report ('.\' + reports[i,1])
		case inlist(justExt(reports[i,1]), 'LBX')
			compile label  ('.\' + reports[i,1])
		otherwise
			assert FALSE		
		endcase
		
	endfor
	
	select (s)
endfunc
*--------------------------------------------------------------------------
(2) If you use set printer to name (xxx) than this is imo most likely to be the cause. Once this has been done you will start getting that error 1958.
This is the sequence that leads to that error
- set printer to name (someprinter)
- report form .....
- set printer to name (oldprinter)
- ...
- set priner to name (someprinter)
- report form .... bingo, the error

The only way I have found to get around this is to avoid using set printer to name and directly change the windows printer prior to printing the report.
&& to change the printer
local sPrint
=Printer_Set('PrinterNameIwantToUse', @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
*-------------------------------------------------------------------------------
Success,
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform