04-14-2006, 07:28 AM
Create new member function ExcelSheet.Init2 and paste this.
function $book [VARIANT'sheet] [activatebook] [activatesheet]
;Same as Init, but also allows you to specify workbook (file name).
;EXAMPLE
;ExcelSheet es.Init2("Book1.xls" "Sheet2")
;
Excel.Application xlApp._getactive
err
,int h=win; act "+Shell_TrayWnd"; act h
,xlApp._getactive
Excel.Workbook wb=xlApp.Workbooks.Item(book)
if(activatebook) wb.Activate
int good
sel sheet.vt
,case [VT_I4,VT_DISPATCH] good=sheet.lVal
,case VT_BSTR good=sheet.bstrVal.len
if(good)
,ws=wb.Worksheets.Item(sheet)
,if(activatesheet) ws.Activate
else ws=wb.ActiveSheet
err+ end _error