Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cells orphaned from update precedence tree - test condition? G Lykos Excel Programming 0 August 7th 07 08:00 AM
detecting application idle time in Excel 2000 salmosalar Excel Programming 0 February 3rd 07 03:30 AM
Orphaned Menu Item ExcelMonkey Excel Programming 2 February 15th 06 05:59 PM
Detecting Applications Run using Excel gr8guy Excel Programming 2 August 16th 04 08:16 AM
Detecting Excel 97 using VBA Casper Hornstrup[_2_] Excel Programming 4 June 24th 04 04:28 AM


All times are GMT +1. The time now is 03:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"