Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

vba See if a web page is already open

Posted on 2013-12-05
2
Medium Priority
?
2,414 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

971 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