I have a script that works fine with the older version of kix (windows 2003 server) but not the newest one.
I am using a text file to identify excel tabs and print to pdf995. My problem is that during the process, the information inside the pdf belongs to a different person than is labeled.
This is the entire script (I have tried to make it generic as to locations and filenames)'

 Code:
$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


A sample of the setup file:
mlrp0913
ADAMS.VELMA,ADAMS.VELMA,347,NS
ADAMS.VELMA,HUGHS,347,NS
BLAINE.CATHERINE,BLAINE.CATHERINE,254,FP
BLAINE.CATHERINE,BAKER,254,FP
CHAMBERS.EDDIE,CHAMBERS.EDDIE,490,EMER
DOBBS.ELIZABETH,DOBBS.ELIZABETH,7501,IM
DOBBS.ELIZABETH,KNIGHT,7501,IM

filename(less extension)
$doc,$folder,$drno,$spec

You will note that the output file is placed in 2 locations. The problem is the data in the first file - which has the correct name - contains information from a different $doc

Can anyone explain to me, why the $doc information is being corrupted? and how can I fix it?
We are using office 2010 on windows 7 pc's.