Here is the code:
Code:
?@kix
$dt=READVALUE('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders','Desktop')
READEXCEL($dt+'\computers.xls')
FUNCTION READEXCEL($cfilename)
DIM $rc,$row,$oxl,$c
$ldaploc=',ou=Computer,ou=Accounts,ou=Company Name,ou=Companies,dc=DOMAIN,dc=COMPANY,dc=com'
$logfile='H:\USERDETAILS.CSV'
IF 0=EXIST($cfilename) ;insure the file exists
?'Excel file not found'
SLEEP 4
RETURN ;leave
ENDIF
$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($cfilename)
$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
$computer=$oxl.cells($row,1)
?$computer
$objcomputer=GetObject('LDAP://cn='+$computer+$ldaploc)
IF @error=0
$name=$oxl.cells($row,2)
?$name
$objcomputer.put('description',cstr('COMPANY - Location - '+$name))
;@ERROR+' - '+@SERROR
$cube=$oxl.cells($row,3)
?$cube
$objcomputer.put('location',cstr('Cube in Location - '+$cube))
;?'Cube: '+@ERROR+' - '+@SERROR
$objcomputer.setinfo
;?'SetInfo: '+@ERROR+' - '+@SERROR
$objcomputer=0
ELSE ;If it cannot create a valid object
LOGGER($logfile,$computer+@crlf)
ENDIF
ENDIF
LOOP
$oxl.quit ;quit Excel
$oxl=0
ENDFUNCTION
FUNCTION LOGGER($logfile,$logdata)
DIM $n
WHILE Open(1,$logfile,5)<>0
IF $n
'.'
ELSE
? 'Please wait'
ENDIF
$n=$n+1
;IF $n=6
; EXIT(1)
;ENDIF
SLEEP 1
LOOP
$n=WriteLine(1, $logdata)
$n=Close(1)
ENDFUNCTION
Thanks,
Kent