Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

vba See if a web page is already open

Posted on 2013-12-05
2
Medium Priority
?
2,272 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

730 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