View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
EricIsDeliriou5[_2_] EricIsDeliriou5[_2_] is offline
external usenet poster
 
Posts: 1
Default FollowHyperlinks opening multiple browser windows


Hi all.

Here is what I came up with after some serious web searching and a lo
of trial and error.

I originally thought that I could use th
GetObject("","InternetExplorer.Application" to control an open I
window, but for some very technical reasons that I found in the M
Knowledge Base ariticles, you can't do that.... However
CreateObject("InternetExplorer.Application") works great if you want t
spawn a new IE window every time you execute your code.

So I had to add a reference in my VBA to the "Microsoft Interne
Controls", which pointed to the shdocvw.dll file.

I then used the code below to look at the long file name for ever
shell windows that is running to see if one of the shell windows is IE
If one of the shell windows is IE, I set a custom object to tha
window, and then Navigate to the appropirate URL. If there are no I
windows that are open, the windows is very happy to open a new one t
the approripriate URL.

Sub GoToEPMExpress()
Dim sURL As String
Dim bIERunning As Boolean

Set objSW = New SHDocVw.ShellWindows
sURL
"http://myintranetapp:8181/EPM/EPMHome.jsp?businessRequirementID=14"

For Each objIE In objSW
If InStr(1, UCase(objIE.FullName), "IEXPLORE") Then
Set objIE = objSW.Item
bIERunning = True
Exit For
End If
Next objIE

If bIERunning Then
objIE.Navigate sURL
Else
Set IE = CreateObject("InternetExplorer.Application")
With IE
If Len(sURL) Then .Navigate sURL Else .GoHome
Do Until Not .Busy
DoEvents
Loop
.Visible = True
End With
Set IE = Nothing
End If
End Sub


I hope this helps if you're having the same problem with multiple I
windows being created from an Excel app when using the FollowHyperlin
method.

Cheers,
Eric :

--
EricIsDeliriou
-----------------------------------------------------------------------
EricIsDeliriou5's Profile: http://www.excelforum.com/member.php...fo&userid=1562
View this thread: http://www.excelforum.com/showthread.php?threadid=27168