Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Excel and OLE

by Silicon Cactus (Scribe)
on Sep 18, 2002 at 21:00 UTC ( [id://199003]=note: print w/replies, xml ) Need Help??


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.

Replies are listed 'Best First'.
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://199003]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 10:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found