You gave me a perfect idea to solve my problem.
"Tom Lavedas" <tglbatch@xxxxxx> wrote in message
On Aug 15, 1:23 am, "Tim Williams" <timjwilliams at gmail dot com>
> Here's a function which will return a reference to an IE window which has
> given URL. You can use this to get a handle on the new window which opens
> on following the link.
> Dim myIE
> Set myIE = GetIE("http://www.google.com")
> If not myIE is nothing then
> 'do something
> End if
> 'Find and return an IE window with matching URL
> 'Assumes no frames.
> Function GetIE(sAddress)
> Dim objShell , objShellWindows, o
> Dim retVal, sURL
> Set retVal = Nothing
> Set objShell = CreateObject("Shell.Application")
> Set objShellWindows = objShell.Windows
> For Each o In objShellWindows
> sURL = ""
> On Error Resume Next
> sURL = o.document.Location
> On Error GoTo 0
> If sURL <> "" Then
> If ucase(Left(sURL, Len(sAddress))) = ucase(sAddress) Then
> Set retVal = o
> Exit For
> End If
> End If Next o
> Set GetIE = retVal
> End Function
> "jason" <atechm...@xxxxxx> wrote in message
> > "Tim Williams" <timjwilliams at gmail dot com> wrote in message
> >> If you look at the IE window (after setting it visible) what is
> >> displayed
> >> at the end of the code? Is it the expected page ?
> >> Might help to show the actual code you used (ie. include your function
> >> used to ensure page is fully loaded)
> >> "jason" <atechm...@xxxxxx> wrote in message
> >>> Hi there
> >>> I am using vbscript to collect information from web site.
You're on the right track, but the initial problem is that the page
that Jason is referencing does NOT follow a URL at the anchor he is
So, the first thing to do is use an a.click in place of the a.href/
IE.Navigate construct of his example script.
Also, since he doesn't get the new pages URL from the anchor, he is
forced to search for the new window by title. Here's a function that
finds the FIRST occurence of an IE window with a matching part of its
set IEW = FindWindow("How to")
if IEW is Nothing then
wsh.echo "Window not found"
wsh.echo left(IEW.document.body.InnerHTML, 128)
set FindWindow = Nothing
for each wndw in .windows
if instr(lcase(typename(wndw.document)), "htmldocument") > 0
if Instr(lcase(wndw.document.title), lcase(sTitle)) > 0 then
set FindWindow = wndw