I tried making my code more simple, it worked for a while then after about 9 runs of different reports while testing, all of a sudden all reports stopped. I can't even get those that were working to work. I tried cleaning out the temp files and rebooting, but this doesn't seem to be an OS problem. This same series of events happend prior to my changing the code. This was originally Rick Strahl's code which I changed to suit my application.
***************Code
#INCLUDE WCONNECT.H
Set PROCEDURE TO wwPDF ADDITIVE
Set PROCEDURE TO wwEVAL ADDITIVE
*************************************************************
Define CLASS wwPDF50 AS RELATION
*************************************************************
*** Author: Rick Strahl
*** (c) West Wind Technologies, 1999
************************************************************
************************************************************* wwPDF40 :: PrintReport
*********************************
************************************************************Function PrintReport
Lparameters lcReport, lcOutputFile, lcExtraReportClauses, llconsole
Local loEval, ltStart, lnHandle
lcExtraReportClauses=IIF(EMPTY(lcExtraReportClauses),"",lcExtraReportClauses)
This.cErrorMsg = ""
*** Make sure we erase existing file first
Erase (lcOutputFile)
*** Check if we have PDFWriter installed (safely using wweval)
loEval = CREATE("wwEval")
loEval.ExecuteCommand("SET PRINTER TO NAME '" +THIS.cPrinterDriver +"'")
If loEval.lError
Wait window "ERROR: " + loEval.cErrorMessage
This.cErrorMsg = "Couldn't set printer to " + THIS.cPrinterDriver
Return .F.
Endif
*SET PRINTER TO NAME (THIS.cPrinterDriver)
*** We'll create a Postscript Output File
*lcTFile = SYS(2023) + "\" + SYS(2015) + ".ps"
Release pcTFile
Public pcTFile
*pcTFile = SYS(2023) + "\" + SYS(2015) + ".ps"
pcTFile = (ALLTRIM(pchome)+ "\MyFile.ps")
Report FORM (lcReport) &lcExtraReportClauses NOCONSOLE TO FILE &pcTFile
Set PRINTER TO
*** Get rid of the PS file - empty.
*** Distiller will automatically create a PDF file with ps.pdf extension
*** Note: PDFWriter will create two files .ps and .ps.pdf
*** the latter of which contains the actual output data
*If file(pcTFile)
* ERASE (pcTFile)
*Endif
*lcTFile = FORCEEXT(pcTFile,"pdf")
lcTFile = FORCEEXT((ALLTRIM(pchome)+ "\MyFile.ps"),"pdf")
If FILE(lcTFile)
If NOT FILE(lcOutputFile)
Rename (lcTFile) TO (lcOutputFile)
Endif
Else
If FILE(lcTFile)
If NOT FILE(lcOutputFile)
Rename (lcTFile) TO (lcOutputFile)
Endif
Else
&& use for display in pdf
pcadobe="C:\Program Files\Adobe\Acrobat 6.0\Acrobat\Acrobat.exe"
Declare INTEGER ShellExecute IN shell32.dll ;
Integer hndWin, ;
STRING cAction, ;
STRING cFileName, ;
STRING cParams, ;
STRING cDir, ;
INTEGER nShowWin
cAction = "open"
lno=ShellExecute
(0,"open",pcadobe,"MyFile.ps","",1)
Wait WINDOW AT 15,45 timeout 2 "Please save to
Yelpage directory."
Messagebox("Done viewing?")
If FILE((ALLTRIM(pchome)+"MyFile.pdf"))
Copy file (ALLTRIM(pchome)+"MyFile.pdf") TO
(lcOutputFile)
Endif
* This.cErrorMsg = "Output file not created"
* Return .F.
Endif
Endif
If FILE(FULLPATH(JUSTFNAME(lcTFile)))
lcTFile = FULLPATH(JUSTFNAME(lcTFile))
If NOT FILE(lcOutputFile)
Rename (lcTFile) TO (lcOutputFile)
Endif
Else
If FILE(lcTFile)
*** Move the temp file to the actual file name by renaming
If NOT FILE(lcOutputFile)
Rename (lcTFile) TO (lcOutputFile)
Endif
Else
This.cErrorMsg = "Output file not created"
Return .F.
Endif
Endif
Return .T.
Endfunc
* wwPDF :: PrintReport