This is a function created by Kent Dyer that will read excel files.
Code:
;FUNCTION READEXCEL()
;
;ACTION Reads an Excel Spreadsheet
;
;AUTHOR Kent Dyer (leptonator@hotmail.com)
;
;CONTRIBUTORS Alex, Frans Erich for the idea
;
;VERSION 1.4 - re-written for an array
;
;DATE CREATED 02-January-2002
;
;DATE MODIFIED 27-April-2003
;
;KIXTART 4.12
;
;SYNTAX READEXCEL('FILENAME')
;
;PARAMETERS $Filename
; XLS file
;
;DEPENDENCIES None
;
;RETURNS Values - $Value1, $Value2, $Value3
;
;REMARKS
;{Version 1.2 - Edit 06-April-2003 Added additional error-checking}
;{Version 1.1 - Edit 28-October-2002 fixed a "dispatch pointer" error}
;Ref - http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=2&t=002715
;Ref - http://boards.cramsession.com/boards/vbm.asp?rpg=1&wpg=1&sb=0&pvm=False&m=447684
;
;EXAMPLE
;Tested on MS-Excel Files
;$cFile = "C:\Scripts\Test.XLS"
;Tested on CSV Files
;$cFile = "C:\Scripts\Test.CSV"
;READEXCEL($cFile)
;
;KIXTART BBS http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000121
FUNCTION READEXCEL($cfilename)
DIM $Rc,$Row,$oXL
$a=1,3,2 ;columns and order to be read
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
$name=$oXL.cells($Row,1])
ENDIF
LOOP
$READEXCEL=$b
ENDFUNCTION
Browse the UDF library for more UDFs.
http://udf.isorg.com/
_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5