Pavel has asked for the wisdom of the Perl Monks concerning the following question:

Hi, all Perl people!

I'm trying to use OLE objects (IE, actually) via Perl with the following code:

use Win32::OLE qw(EVENTS); unless (defined $ie) { $ie = Win32::OLE->new('InternetExplorer.Application') or die +"Oops, cannot start IE"; } $ie->Navigate('c:\some_dir\some_doc.htm'); while ($ie->Busy) {} $ie->{Visible} = 1; Win32::OLE->MessageLoop(); Win32::OLE->WithEvents($ie, \&Ev);
Ev - the event handling procedure.

IE window with the document loaded appears on screen, but I cannot handle any events - it seems as if my program does not catch them.

Please, help me. I will greatly appreciate any tip or advice or just a code example where OLE events handling by Perl works.

Thank You,
Pavel.

Replies are listed 'Best First'.
Re: How do I handle an OLE object events?
by perlmoth (Hermit) on Dec 10, 2001 at 00:04 UTC
    As far as I rememeber (I am home here, and not on a Windows box) Win32::OLE doesn't handle OLE events (or handles them poorly), only properties and methods. Your best bet is to check out the Win32::OLE mailing list archives on Activestate's website. Someone may have a work-around there.
      I read a suggestion from news: for Excel the third argument of WithEvent() is 'ApplicationEvents'. This not work for InternetExplorer. But i am style wanted for equivalent. I hop this help.
Re: How do I handle an OLE object events?
by LD2 (Curate) on Dec 10, 2001 at 10:50 UTC
    You may want to check the documentation for Win32::OLE on ActiveState.com. It seems to state that Win32::OLE only has alpha level event support. There's some examples in the documentation.
Re: How do I handle an OLE object events?
by NicS (Scribe) on Dec 12, 2001 at 02:29 UTC
    I needed to something similar recently (using Rational Rose REI).
    Win32::OLE is good for making calls to COM objects but not receiving events.

    A friend suggested using ActiveState PerlCOM. The basics are you write the
    interface in a language that has good COM support then invoke your perl script via COM.

    Don't know much more than that, but this article explains in detail Integrating Perl into Microsoft Office Innards


    --

    Nic