Solved

vba See if a web page is already open

Posted on 2013-12-05
2
1,398 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 80

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now