Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris


by chinman (Monk)
on Dec 05, 2001 at 21:47 UTC ( #129677=perlquestion: print w/replies, xml ) Need Help??

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

I've been trying to get the code shown below to work on NT, and it's driving me nuts. It works flawlessly on Win2k, but not on NT 4.0. The GetActiveObject does not seem to return anything, even when several copies of IE may be running. I've searched thru the ActiveState mailing lists, etc, but I can't find any solution or workaround for the problem. Any ideas?
#!/usr/bin/perl -w use strict; my $file = 'C:\temp\index.html'; display_browser("$file"); ##subroutine that supposedly displays a file in IE browser window sub display_browser { my $file = shift; ## convert backslashes to forward slashes in the file path $file =~ s!\\!/!g; if ( $^O eq "MSWin32" and "$file" and -e "$file" ) { use Win32::OLE; ## test to see if internet explorer is already running my $ie = Win32::OLE->GetActiveObject('InternetExplorer.Applica +tion'); ## if ie is not running, launch it, yeah right! unless ( defined $ie ) { $ie = new Win32::OLE( 'InternetExplorer.Application', '' ) + or die "Yikes, can't launch Internet Explorer: $!"; } ## if we were successful in launching, make visible and naviga +te to the proper URL if ( defined $ie ) { $ie->{Visible} = 1; $ie->Navigate("$file"); } } }

Replies are listed 'Best First'.
Re: Win32::OLE-GetActiveObject
by c-era (Curate) on Dec 06, 2001 at 00:43 UTC
    Your code is right. The problem is with IE versions <5.003. Those versions doesn't register its self when active, so getactiveobject will fail. The reason it works on your 2k box is, a version of IE >5.00.3 is alread loaded.
      Interesting...I have an NT machine that's running IE 5.5 and the GetActiveObject still appears to fail. Yuk.

        I have 4 computers all using a similar version of Windows 98, Internet Explorer and Perl, 3 of which are unable to get an internet explorer active object. I have tried to identify what possible difference in configuration there is between the successful one and the other 3 but have so far been unable to. Any suggestions?

    Log In?

    What's my password?
    Create A New User
    Domain Nodelet?
    Node Status?
    node history
    Node Type: perlquestion [id://129677]
    Approved by root
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (1)
    As of 2022-08-10 01:37 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found