cancel
Showing results for 
Search instead for 
Did you mean: 

Calling IE and adding a new tab

Former Member
0 Kudos

I have a need where I need to call Internet Explorer using PB 12.1 classic. If IE is already opened, I want to create a new tab, not start a new instance of IE. IE might not be the default browser on the users PC.

As far as I can tell, the INET object simply calls the default browser, so I cannot rely on that.

Using a run(iexplore.exe  url) works, but it will create new instances of IE, Any suggestions?

Upgrading to a later PB is not an option, using a different browser is not an option.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Something like this should work for you:

oleobject lole_ie, lole_shell, lole_shellwindows

integer i

lole_shell = CREATE oleobject

lole_shell.Connecttonewobject("Shell.Application")

lole_shellwindows = lole_shell.Windows()

For i = 0 To lole_shellwindows.Count - 1

    If Pos (upper (lole_shellwindows.Item(i).FullName), "IEXPLORE.EXE") > 0 Then

        lole_ie = lole_ShellWindows.Item(i)

        Exit

    End If

Next

IF IsValid (lole_ie) THEN

    lole_ie.Navigate2 (ls_url, 2048) // open in new tab

ELSE

    lole_ie = CREATE oleobject

    lole_ie.Connecttonewobject("InternetExplorer.Application")

    lole_ie.Navigate2 (ls_url) //no need for new tab here ?

    lole_ie.visible = 1

END IF

lole_shell.Disconnectobject( )

lole_ie.Disconnectobject( )

DESTROY lole_ie

DESTROY lole_shell

Former Member
0 Kudos

Tested this and it works like a charm.

Thank you!

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Terry;

I am thinking that some sort of OLE interaction might do the trick. Have a read through Real's thoughts on this approach ....  Use Internet Explorer - Real's Powerbuilder Howto

HTH

Regards ... Chris

Former Member
0 Kudos

Hello Terry,

my first thought was OLE. I haven't had time to try this but have had plenty of success with Word and Excel....

https://msdn.microsoft.com/en-au/library/aa752084(v=vs.85).aspx

HTH, Paul

Former Member
0 Kudos

You can specify 2048 as second parameter of methods Navigate and Navigate2 to open a url on a new tab. Navigate method (Windows)

But I have no clue how to connect to an existing instance of IE. ConnectToNewObject("InternetExplorer.Application") seems always to start a new instance.

Former Member
0 Kudos

It seems it is not possible to connect to an existing instance of IE using ConnectToObject. The reason is that IE instances are not available in the running object table (ROT) because of security reasons.

see this Microsoft article