Made a couple of changes.. It became easier to look for login id versus full name..
Code:
CLS
BREAK ON
$logfl='H:\Gemini Move\phon.csv'
IF EXIST($logfl)
DEL $logfl
ENDIF
LOGGER($logfl,'Login,Name,Phone'+@CRLF)
$oxl=Createobject('Excel.application')
;Check to insure that Excel is available
IF 0<>@error ?@error ' Excel Application is not found'
SLEEP 4
RETURN
ENDIF
$rc=$oxl.workbooks.open("H:\Gemini Move\employee phone exts.xls")
$row=1 ;Row to start at using column headings, change to 0, if needed
WHILE $oxl.cells($row,1).value<>'' ;need a value each time in column 1
$row=$row+1
IF $oxl.cells($row,1).value='' ;Once it gets to a blank row...
$oxl.quit ;quit Excel
$oxl=0 ;set the object to 0
ELSE
$login=$oxl.cells($row,1).value
;$fname=$oxl.cells($row,2).value
;$lname=$oxl.cells($row,3).value
;$fullname=$fname+' '+$lname
;?$fullname
$aattributes = "Name", "AdsPath"
$sadspath = "LDAP://"+GetObject("LDAP://rootDSE").get("defaultNamingContext")
;$strFilter = "(&(objectClass=User)(Name=*))"
;$strfilter = "(&(objectClass=User)(Name="+$fullname+"))"
$strFilter = "(&(objectClass=User)(sAMAccountName="+$login+"))"
$aresults = fnLDAPQuery($aattributes,$sadspath,$strfilter,"Name")
;@error " | " @serror ;?
For $r = 0 to UBound($aResults)
;"ADsPath: " + $aResults[$r,1] ?
$user = GetObject($aResults[$r,1])
;?RIGHT($user.name,LEN($user.name)-3)
?"Name: " + $aResults[$r,0]
?$user.telephonenumber
?$user.sAMAccountName
; -- Set the new Phone Number
;$user.Put("telephoneNumber", "(000) 123-"+$oxl.cells($row,4).value)
;$user.SetInfo
LOGGER($logfl,$user.sAMAccountName+','+$aResults[$r,0]+','+$user.telephonenumber+@CRLF)
Next
ENDIF
LOOP
?"Process is complete.. Press a Key"
GET $
Thanks,
Kent