;------------------------------------------------------------------------------
; Name: excel.kix
;------------------------------------------------------------------------------
break on
$=setoption('Explicit','ON')
$=setoption('WrapAtEOL','ON')
$=setoption('NoVarsInStrings','ON')
main
Quit 0
;------------------------------------------------------------------------------
Function main()
Dim $rc
Dim $filename
Dim $autofilters
Dim $xl
Dim $wb
Dim $ws
Dim $rng
$filename = "c:\fred.xls"
$autofilters = "Y"
; Start excel.
$xl = CreateObject("Excel.Application")
if @error
messagebox ("Errors detected starting excel...", "Unable to run command.", 0, 5)
quit 1
endif
$xl.Visible = True
$xl.DisplayAlerts = 0
if exist($filename) ; if the file exists, open it
$wb = $xl.Workbooks.Open($filename)
$ws = $wb.WorkSheets(1)
$rng = $ws.Range("A1:CC2000")
if $autofilters = "Y"
$rng.Rows("1:1").Select
$rng.AutoFilter
$ws.Range("A2").Select
endif
$rng.Cells.Select
$rng.Cells.EntireColumn.AutoFit
$ws.Range("A1").Select
endif
exit @ERROR
EndFunction
;------------------------------------------------------------------------------