Solved

vba See if a web page is already open

Posted on 2013-12-05
2
1,610 Views
Last Modified: 2013-12-05
vba

Is the any code to tell me if any web page in IE is already open to a certain website.

So if i wanted to know if any of my browser pages are open to google..

if it is go to that page.

Thanks
fordraiders
0
Comment
Question by:fordraiders
2 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 500 total points
ID: 39700140
Here are a sub and function that work together to find a webpage whose URL begins with http://www.google.com  If one is found, the URL is displayed in a MsgBox.
Sub TestURLmatch()
Dim ie As Object
Dim sMatch As String
sMatch = "http://www.google.com"
On Error Resume Next
Set ie = GetIEatURL(sMatch & "*")
On Error GoTo 0
If Not ie Is Nothing Then
    MsgBox "Found webpage at " & ie.LocationURL
End If
End Sub

Function GetIEatURL(sMatch As String) As Object
Dim ie As Object, oShApp As Object, oWin As Object
Set oShApp = CreateObject("Shell.Application")
For Each oWin In oShApp.Windows
    If TypeName(oWin.Document) = "HTMLDocument" Then
        Set ie = oWin
        If LCase(ie.LocationURL) Like LCase(sMatch) Then
            Set GetIEatURL = ie
            Exit For
        End If
    End If
Next
Set oShApp = Nothing
Set oWin = Nothing

End Function

Open in new window

0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 39700231
Thannk you for all the help !!!!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question