Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Cole
 
Posts: n/a
Default How to Show Existing IE Instance if Already Exists, Else Open One

Hi folks,
I'm trying to do the following:
Test to see if Internet Explorer already has an instance open to address "www.mypage.com", for instance.
If it is already open, then change focus to that existing window.
If it is not already open, then start a new instance of IE with that URL.


I've got many years as a programmer, but new to this language. I did
find the following code that looks close to what I want, but I get an
error msg that reads: "User-defined type not defined" - referencing the
variable "objSW As SHDocVw.ShellWindows"

Here is the code I found:

Dim objSW As SHDocVw.ShellWindows
Dim objIE As SHDocVw.InternetExplorer
Dim objDoc As Object

Set objSW = New SHDocVw.ShellWindows
If objSW.Count Then ' new
For Each objIE In objSW
If InStr(1, objIE.FullName, "mypage") Then
Set objIE = objSW.Item
fAppRunning = True
Exit For
Else
Set objIE = CreateObject("InternetExplorer.Application")
End If
Next objIE
Else ' new
Set objIE = CreateObject("InternetExplorer.Application") ' new
End If

objIE.Visible = True

objIE.Navigate "www.mypage.com"

Set objDoc = Nothing
Set objIE = Nothing
Set objSW = Nothing

THANK YOU for your help. GREATLY APPRECIATED!
Kind regards,
Cole

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't Open Files KenP Excel Discussion (Misc queries) 1 April 21st 06 03:54 AM
i try to open Excel spreadsheets, and they open in wordpad-- mikekeat Excel Discussion (Misc queries) 2 October 1st 05 10:13 PM
cannot open an xl97 file maxzsim Excel Discussion (Misc queries) 1 June 24th 05 12:29 PM
Show Existing Names hk29 Excel Discussion (Misc queries) 2 April 21st 05 06:21 PM
Sumif Linking to Another Workbook error #VALUE! Tunde Excel Discussion (Misc queries) 16 March 4th 05 03:02 AM


All times are GMT +1. The time now is 07:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"