Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Report going to default printer no matter what the setti
Message
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00929314
Message ID:
00932318
Views:
19
Here is code I got from Yuri on the UT that I now run on all of my VFP7 reports before deploying:
* Yuri Rubinov July 2000
* Remove printer specific setting in report form
*---------------------------------------------------

PARAMETER pRepoForm
CLEAR
LOCAL lcdefault, llokay, cleancolors
lcdefault=UPPER(SYS(2003))
cleancolors=.F.	&& false is do NOT change the colors
IF TYPE("pRepoForM")#"C"
	LOCAL lcnewdefault
	lcnewdefault=GETDIR()
	IF !EMPTY(lcnewdefault)
		SET DEFAULT TO (lcnewdefault)
		pRepoForm="ALL"
	ELSE
		pRepoForm=GETFILE("frx")
	ENDIF
ENDIF

DO CASE
	CASE UPPER(pRepoForm)#"ALL"
		pRepoForm=LOWER(pRepoForm)
		IF NOT ".frx"$pRepoForm
			pRepoForm=pRepoForm+".frx"
		ENDIF
		IF NOT FILE(pRepoForm)
			pRepoForm=GETFILE("frx")
			IF NOT ".frx"$pRepoForm
				pRepoForm=pRepoForm+".frx"
			ENDIF
			IF NOT FILE(pRepoForm)
				=MESSAGEBOX("Report Form "+pRepoForm +" not found?!")
				RETURN
			ENDIF
		ENDIF
		DO iClean WITH cleancolors
	OTHERWISE
		*WHAT ABOUT PAGE Orientation?
		IF ADIR(aa,"*.frx")<=0
			=MESSAGEBOX("No *.frx Report Forms found?!")
			RETURN
		ENDIF
		FOR ia =1 TO ALEN(aa,1)
			pRepoForm=aa[ia,1]
			DO iClean WITH cleancolors
		ENDFOR

ENDCASE
llokay=IIF(UPPER(lcdefault)=UPPER(SYS(2003)),.T.,.F.)
IF !llokay
	SET DEFAULT TO (lcdefault)
ENDIF
RETURN
*----------------------------------
PROCEDURE iClean
PARAMETERS cleancolors

CLOSE TABLE ALL
USE (pRepoForm)
WAIT WIND "Fixing Report form "+DBF() NOWAIT
=AFIELD(afld)
* the very first record only
IF ASCAN(afld,"TAG")#0 AND ASCAN(afld,"TAG2")#0 AND ASCAN(afld,"EXPR")#0
	GO TOP
	*keep orientation and number of copies
	lcExpr1=""
	lcExpr = "COPIES=1"
	lcorient="ORIENTATION=0"
	IF "orientation"$LOWER(EXPR)
		lnOrientation = ATC("ORIENTATION", EXPR)
		lcorient="ORIENTATION" + ;
			SUBSTR(EXPR, ;
			lnOrientation + 11, 02)
	ENDIF
	IF "copies"$LOWER(EXPR)
		lcExpr=SUBSTR(EXPR,AT("copies=",LOWER(EXPR)),8)
	ENDIF
	lcExpr1=lcorient+CHR(13)+lcExpr+CHR(13)
	REPLACE TAG WITH "", tag2 WITH "", EXPR WITH lcExpr1
	? "*******************"
	? EXPR
ELSE
	=MESSAGEBOX("File "+pRepoForm+". Not VFP6 format?!")
ENDIF
GO TOP
SCAN
	IF cleancolors	&& force lines and text boxes to black on white
		DO CASE
		CASE objtype=6	&& lines (-1=default color setting of desktop)
			IF fillred=-1
				REPLACE fillred WITH 255
			ENDIF
			IF fillgreen=-1
				REPLACE fillgreen WITH 255
			ENDIF
			IF fillblue=-1
				REPLACE fillblue WITH 255
			ENDIF
*!*				IF fillred=-1	&& background
*!*					REPLACE fillred WITH 0
*!*				ENDIF
*!*				IF fillgreen=-1
*!*					REPLACE fillgreen WITH 0
*!*				ENDIF
*!*				IF fillblue=-1
*!*					REPLACE fillblue WITH 0
*!*				ENDIF
			IF penred=-1	&& forground
				REPLACE penred WITH 0
			ENDIF
			IF pengreen=-1
				REPLACE pengreen WITH 0
			ENDIF
			IF penblue=-1
				REPLACE penblue WITH 0
			ENDIF
		CASE objtype=8 && fields
			IF penred=-1
				REPLACE penred WITH 0
			ENDIF
			IF pengreen=-1
				REPLACE pengreen WITH 0
			ENDIF
			IF penblue=-1
				REPLACE penblue WITH 0
			ENDIF
			IF fillred=-1
				REPLACE fillred WITH 255
			ENDIF
			IF fillgreen=-1
				REPLACE fillgreen WITH 255
			ENDIF
			IF fillblue=-1
				REPLACE fillblue WITH 255
			ENDIF
		CASE objtype=7 && shapes
		CASE objtype=5	&& text only
			IF penred=-1
				REPLACE penred WITH 0
			ENDIF
			IF pengreen=-1
				REPLACE pengreen WITH 0
			ENDIF
			IF penblue=-1
				REPLACE penblue WITH 0
			ENDIF
			IF fillred=-1
				REPLACE fillred WITH 255
			ENDIF
			IF fillgreen=-1
				REPLACE fillgreen WITH 255
			ENDIF
			IF fillblue=-1
				REPLACE fillblue WITH 255
			ENDIF
		ENDCASE
	ENDIF
ENDSCAN
USE
*!*	SET SAFETY OFF
gfile=LEFT(pRepoForm,RAT(".",pRepoForm)-1)+".*"
*!*	copy file &gFile TO "c:\DEVUPDATES\reports32"
*!*	copy file &gFile TO "l:\DEVUPDATES\reports32"
*!*	copy file &gFile TO "z:\DEVUPDATES\reports32"
*!*	copy file &gFile TO c:\profilermodssave
*!*	copy file &gFile TO z:\profilermodssave
?gfile
RETURN



*******************
DRIVER=winspool
DEVICE=\\NCSERVER\HP LaserJet 4000 Series PCL 6
OUTPUT=Ne02:
ORIENTATION=0
PAPERSIZE=1
PAPERLENGTH=2794
PAPERWIDTH=2159
COPIES=1
DEFAULTSOURCE=15
PRINTQUALITY=600
DUPLEX=1
YRESOLUTION=600
TTOPTION=2
*******************
LPARAMETERS cOutputName, nBuildAction, lRebuildAll, lShowErrors, lBuildNewGuids
LOCAL loCurrentProject
LOCAL lcOldALIAS
LOCAL lnCounter

loCurrentProject = APPLICATION.ACTIVEPROJECT
lcOldALIAS = ALIAS()

WITH loCurrentProject
	WITH .FILES
		SELECT 0
		WAIT WINDOW "Looking for FRXs to scrub . . ." NOWAIT
		FOR lnCounter = 1 TO .COUNT
			WITH .ITEM(lnCounter)
				IF .TYPE = FILETYPE_REPORT
					WAIT WINDOW "Scrubbing FRXs . . ." NOWAIT
					USE (.NAME) ALIAS ReportFRX
					lcExpr = "COPIES=1"
					lnOrientation = ATC("ORIENTATION", ReportFRX.EXPR)
					IF lnOrientation > 0
						lcExpr = lcExpr + ;
							dHardReturn + ;
							"ORIENTATION" + ;
							SUBSTR(ReportFRX.EXPR, ;
							lnOrientation + 11, 02)
					ENDIF
					REPLACE ReportFRX.EXPR WITH lcExpr, ;
						ReportFRX.TAG  WITH dNULString, ;
						ReportFRX.tag2 WITH dNULString
					USE IN ReportFRX
				ENDIF
			ENDWITH
		ENDFOR
		WAIT CLEAR
	ENDWITH
ENDWITH
IF NOT EMPTY(lcOldALIAS)
	SELECT (lcOldALIAS)
ENDIF
DODEFAULT(cOutputName, nBuildAction, lRebuildAll, lShowErrors, lBuildNewGuids)
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform