Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Detecting an orphaned Excel.Application
I sometimes create an Excel.Application object, and use that to open
another workbook, read the contents, then close and quit it. If my code crashes or if I interrupt it, the application object stays running and still has the workbook open. The only way that I have of tidying this up is to close any other Excel spreadsheets that I have open and quit out, then open a spreadsheet by double-clicking on it, this will make Excel notice that there is an Excel application object already running and re-use that to open the workbook, and then I can see that it has another workbook already open, and I can quit it. Is there any other way to detect a hidden Excel application instance that is running hidden, and specifically direct it to close? Other than running Task Manager and forcing EXCEL.EXE to close, I mean, is there anything I can do within an Excel macro to tidy it up? Phil Hibbs. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Detecting an orphaned Excel.Application
The first thing to do would be to add an error handler that closes the
running Excel instance if an error occurs. That would handle the cases where the code causes an error. The other thing to do would be to use FindWindow and FindWindowEx APIs to see if you can grab the Excel window (as you expect it to exist). --JP On Feb 2, 10:56*am, Phil Hibbs wrote: I sometimes create an Excel.Application object, and use that to open another workbook, read the contents, then close and quit it. If my code crashes or if I interrupt it, the application object stays running and still has the workbook open. The only way that I have of tidying this up is to close any other Excel spreadsheets that I have open and quit out, then open a spreadsheet by double-clicking on it, this will make Excel notice that there is an Excel application object already running and re-use that to open the workbook, and then I can see that it has another workbook already open, and I can quit it. Is there any other way to detect a hidden Excel application instance that is running hidden, and specifically direct it to close? Other than running Task Manager and forcing EXCEL.EXE to close, I mean, is there anything I can do within an Excel macro to tidy it up? Phil Hibbs. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Cells orphaned from update precedence tree - test condition? | Excel Programming | |||
detecting application idle time in Excel 2000 | Excel Programming | |||
Orphaned Menu Item | Excel Programming | |||
Detecting Applications Run using Excel | Excel Programming | |||
Detecting Excel 97 using VBA | Excel Programming |