Solved

vba See if a web page is already open

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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 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.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

728 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