I wrote a script that takes an Excel spreadsheet and outputs it to an.ldf which I will import later to populate the telephoneNumber field in AD. Everything works properly except the $ext variable does not output any data. It appears that the problem is because the $ext field is an integer, since I can add text to the field in Excel and it starts working.

I am posting the code minus the ReadExcel2 UDF. Any help with this problem would be appreciated.

Code:
 Break ON
$phones = ReadExcel2('c:\phone list.xls',,-1,5)
For $counter=1 to ubound($phones,1)
$Ext=$phones[$counter,0]
$givenName=$phones[$counter,2]
$extra=$phones[$counter,4]
$sn=$phones[$counter,3]
$sn=$phones[$counter,3]

IF $extra=""
$sn=$phones[$counter,3]
Else $sn=Left($phones[$counter,3],1)+$extra
ENDIF
$cn=Left($givenName,1)+$sn
$cn8=Left($givenName,1)+Left($sn,7)
$DN="CN=$cn,OU=mycity,DC=mydomain,DC=com"
$DN2="CN=$cn8,OU=mycity,DC=mydomain,DC=com"

Open(1,"c:\extensionsrb.ldf",5)
WriteLine(1,"DN: $DN"+ Chr(13) + Chr(10))
WriteLine(1,"changetype: modify"+ Chr(13) + Chr(10))

WriteLine(1,"replace: telephoneNumber"+ Chr(13) + Chr(10))
WriteLine(1,"telephoneNumber: $ext"+ Chr(13) + Chr(10))
WriteLine(1,"-"+ Chr(13) + Chr(10))
WriteLine(1,Chr(13) + Chr(10))

IF $DN<>$DN2
WriteLine(1,"DN: $DN2"+ Chr(13) + Chr(10))
WriteLine(1,"changetype: modify"+ Chr(13) + Chr(10))

WriteLine(1,"replace: telephoneNumber"+ Chr(13) + Chr(10))
WriteLine(1,"telephoneNumber: $ext"+ Chr(13) + Chr(10))
WriteLine(1,"-"+ Chr(13) + Chr(10))
WriteLine(1,Chr(13) + Chr(10))
ENDIF


Next