in reply to Re: Excel and OLE in thread Excel and OLE
You should be able to "watch" the excel window using Win32::API, once you get the window handle.
You could conceivably just check for the existence of the window handle repeatedly in a loop, breaking out of it when the handle is destroyed. Just make sure to stick a sleep statement in there so you don't max out your processor in the loop.
Re: Re: Re: Excel and OLE
by jsprat (Curate) on Sep 19, 2002 at 01:51 UTC
|
Right you are! The FindWindow API lets you search by window class or exact window title, or you can use EnumWindows and check title bar text for a partial match.I was trying to point out the potential pitfalls without being too wordy (or too discouraging - there might be a better way to do it;). The original snippet grabs the existing instance of Excel if it is running. If it was already open and the user closes the document, Excel is still running. Or if the end user forgets to close Excel (or maybe just minimizes it and thinks it is closed) Excel is still running - with the same Window class, maybe even with the same window title. I did something like this once in VB and it turned into a major support headache for me. | [reply] |
|