$home = "K:\Doctor Reports\"
$setup = "\\<server>\mis\reports\PArvu.txt"
;open txt file with tab names and email addresses
IF Open(1, "$setup") = 0
$drfile = ReadLine(1)
ELSE
BEEP
? "Doc file not opened, error code: [" + @ERROR + "]"
sleep 5
EXIT
ENDIF
USE T: "\\<server2>\<dir>\123r4w"
$thismo = @monthno -1
IF $thismo = 0
$month = "12"
ELSE
IF $thismo > 9
$month = CSTR($thismo)
ELSE
$month = "0" + CSTR($thismo)
ENDIF
ENDIF
$year = IIf(@MONTHNO = 1, @YEAR -1, @YEAR)
$readerr = 0
;open Excel file
$app = CreateObject("Excel.Application")
;$app.visible = 1
;Create the Workbooks object
$wbs = $app.Workbooks
$rc = $wbs.Open("T:\Sherry\$drfile.xls",0)
?"drfile = "$drfile
;main program loop
WHILE $readerr = 0
$x = ReadLine(1)
$readerr = @ERROR
$doc = SUBSTR($x, 1, INSTR($x, ",")-1)
$x = SUBSTR($x, INSTR($x, ",")+1, LEN($x) - INSTR($x, ","))
$folder = SUBSTR($x, 1, INSTR($x, ",")-1)
$x = SUBSTR($x, INSTR($x, ",")+1, LEN($x) - INSTR($x, ","))
$drno = SUBSTR($x, 1, INSTR($x, ",")-1)
$x = SUBSTR($x, INSTR($x, ",")+1, LEN($x) - INSTR($x, ","))
$spec = SUBSTR($x, 1, LEN($x) - INSTR($x, ","))
?$doc
IF $doc <> ""
WriteProfileString("C:\Program Files\pdf995\res\pdf995.ini","Parameters","Output File","$home$folder\Recap Reports\$doc-Recap-$year-$month.pdf")
$rc.Worksheets("$doc").PrintOut(,,,,"PDF995")
sleep 3
WriteProfileString("C:\Program Files\pdf995\res\pdf995.ini","Parameters","Output File","$home$folder\(Current Month)\$doc-Recap-$year-$month.pdf")
$rc.Worksheets("$doc").PrintOut(,,,,"PDF995")
sleep 3
Else
?"doc is blank"
ENDIF
LOOP
WriteProfileString("C:\Program Files\pdf995\res\pdf995.ini","Parameters","User File"," ")
WriteProfileString("C:\Program Files\pdf995\res\pdf995.ini","Parameters","Initial Dir"," ")
WriteProfileString("C:\Program Files\pdf995\res\pdf995.ini","Parameters","Launch"," ")
WriteProfileString("C:\Program Files\pdf995\res\pdf995.ini","Parameters","Output File"," ")
$ = Close (1)
;IMPORTANT--YOU MUST CLOSE THE WORKBOOKS OBJECT OR ELSE
; THE EXCEL PROCESS WILL NOT TERMINATE!!!
$wbs.Close
;Destroy the Worksheet, Workbooks, and Application objects
$wbs = 0
$app = 0
USE LIST
USE T: /DELETE
USE LIST