04-22-2006, 09:45 AM
You can start Excel invisible, and open the file:
The problem is that, if an error occurs, app.Quit is not executed, and Excel does not exit, and you'll have to end EXCEL process in Task Manager. To solve this problem, use this instead:
Function ExcelQuit
str sfile="$personal$\book1.xls"
str ssheet="Sheet2"
Excel.Application app._create
;app.Visible=TRUE ;;uncomment to make Excel visible
Excel.Workbook book=app.Workbooks.Open(_s.expandpath(sfile))
ExcelSheet es.ws=book.Worksheets.Item(ssheet)
;now you can get/set cells using es
str s
es.GetCell(s 2 2)
out s
es.SetCell("newvalue" 2 2)
book.Save
app.QuitThe problem is that, if an error occurs, app.Quit is not executed, and Excel does not exit, and you'll have to end EXCEL process in Task Manager. To solve this problem, use this instead:
str sfile="$personal$\book1.xls"
str ssheet="Sheet2"
Excel.Application app._create
atend ExcelQuit &app
;app.Visible=TRUE ;;uncomment to make Excel visible
Excel.Workbook book=app.Workbooks.Open(_s.expandpath(sfile))
ExcelSheet es.ws=book.Worksheets.Item(ssheet)
;now you can get/set cells using es
str s
es.GetCell(s 2 2)
out s
es.SetCell("newvalue" 2 2)
book.SaveFunction ExcelQuit
