fredrerik84
Active Member
- Joined
- Feb 26, 2017
- Messages
- 383
Hi guys im trying to control an webpage that is already open but so far im not able to get it to work.
here is what I have:
I found this code trough a google search but I can not get it to work ., Is there a brilliant mind in here that maybe could give a few pointer to what im doing wrong?
here is what I have:
Code:
Sub google()
Dim IE As New SHDocVw.InternetExplorer
Dim HTMLDoc As New MSHTML.HTMLDocument
Dim HTMLRows As MSHTML.IHTMLElementCollection
Dim HTMLRows2 As MSHTML.IHTMLElementCollection
Dim HTMLRows3 As MSHTML.IHTMLElementCollection
Dim HTMLRows4 As MSHTML.IHTMLElementCollection
Dim HTMLRows5 As MSHTML.IHTMLElementCollection
Dim HTMLRow As MSHTML.IHTMLElement
Dim Doc As HTMLDocument
Dim i As Long
Dim j As Long
Dim k As Long
Dim x As Long
Dim lr As Long
Dim Url As String
Dim matched As String
Dim wb As Worksheet
Set wb = ActiveWorkbook.sheets("Conversion")
Dim mycur As String
Dim marker As Long
Dim objShell
Dim IE_count
Dim my_url
Dim my_title
marker = 0
Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count
For x = 0 To (IE_count - 1)
On Error Resume Next ' sometimes more web pages are counted than are open
my_url = objShell.Windows(x).******************
my_title = objShell.Windows(x).document.Title
If my_title Like "https://www.google.no/?gfe_rd=cr&ei=laCBWeyuEeXk8AeflIGgDw" & "*" Then 'compare to find if the desired web page is already open
Set IE = objShell.Windows(x)
marker = 1
Exit For
Else
End If
Next
If marker = 0 Then
MsgBox ("A matching webpage was NOT found")
Else
MsgBox ("A matching webpage was found")
End If
End Sub
I found this code trough a google search but I can not get it to work ., Is there a brilliant mind in here that maybe could give a few pointer to what im doing wrong?