FUNCTION ConvertFrxToA4 LPARAMETERS tcReportFrx, cOrientation LOCAL lcOrientation, lcExpression, lcTempAlias, lcExtName, oError IF PCOUNT() < 2 cOrientation = '0' && Portrate ENDIF lcExtName = "" TRY lcOrientation = cOrientation && '0' && Portrate lcTempAlias = SYS(2015) *-- Set papersize and orientation. TEXT TO lcExpression TEXTMERGE NOSHOW ORIENTATION=<<lcOrientation>> PAPERSIZE=<<'9'>> COLOR=2 ENDTEXT *-- Create a unique name for the report frx in the temp folder lcExtName = FORCEPATH( "RPT_" + TRANSFORM(_VFP.PROCESSID) + "_" + SUBSTR(SYS(2015),3,10), GETENV("temp")) *-- Copy the the report FRX and FRT files to the temp file name STRTOFILE(FILETOSTR(FORCEEXT(tcReportFrx, 'FRX')), m.lcExtName+".FRX") STRTOFILE(FILETOSTR(FORCEEXT(tcReportFrx, 'FRT')), m.lcExtName+".FRT") USE (m.lcExtName+".FRX") ALIAS (lcTempAlias) IN 0 REPLACE Expr WITH m.lcExpression IN (lcTempAlias) USE IN SELECT(lcTempAlias) CATCH TO oError m.lcExtName = "" MESSAGEBOX("Failed to convert report to A4 size paper" + CHR(13) + CHR(13) + ; "Error message: " + oError.message,48,"Problem Alert!",30000) ENDTRY RETURN (m.lcExtName)