C
cole.simonson
Hi folks,
I'm trying to do the following:
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 in advance for your help. GREATLY APPRECIATED!
Kind regards,
Cole
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 in advance for your help. GREATLY APPRECIATED!
Kind regards,
Cole