Page 1 of 1
Excell remains active
Posted: Tue Aug 14, 2012 7:11 am
by skiman
Hi,
I'm using activeX to read some XLS files.
When the import is done, I have a 'oExcel:Destroy()'. If I check with Taskmanager, it looks as Excel remains active after this destroy.
Some hints to prevent this? Or correct way to stop Excel?
Re: Excell remains active
Posted: Tue Aug 14, 2012 8:16 am
by rdonnay
This is my code from DC_WorkArea2Excel():
Code: Select all
oSheet:destroy()
oBook:close()
oBook:destroy()
// Quit Excel
oExcel:Quit()
oExcel:Destroy()
Re: Excell remains active
Posted: Tue Aug 14, 2012 9:35 am
by skiman
Thanks Roger,
Problem is solved.
Finding the last row of a sheet isn't very simple to find. In case anyone ever needs this, the following seems to work correctly:
oUsedRange := oSheet:usedrange
nMaxLines := oUsedrange:rows:count()
Re: Excell remains active
Posted: Tue Aug 14, 2012 10:29 pm
by Koverhage
Chris,
or this way
oBook:Worksheets(1):activate() // Activate sheet
oSheet := oBook:Worksheets(1) // Shortcut
oExcel:Application:ActiveCell:SpecialCells(xlLastCell):Select
nRow := oExcel:Application:ActiveCell:Row
Re: Excell remains active
Posted: Wed Aug 15, 2012 9:13 am
by rdonnay
I receive the entire worksheet into an array with the following:
Code: Select all
aValues := oBook:workSheets(1):usedRange:value