Hi Tom,
You gave me a perfect idea to solve my problem.
Many thanks!
Jason
"Tom Lavedas" <tglbatch@xxxxxx> wrote in message
news:72c24022-f9c1-4d0c-9512-5387291cdfe7@xxxxxx
On Aug 15, 1:23 am, "Tim Williams" <timjwilliams at gmail dot com>
wrote:
> Here's a function which will return a reference to an IE window which has
> a
> given URL. You can use this to get a handle on the new window which opens
> on following the link.
>
> Tim
>
> Usage:
> 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
>
> news:OxB2rbm$IHA.3380@xxxxxx {snip}
> > "Tim Williams" <timjwilliams at gmail dot com> wrote in message
> >news:OdDUSTE$IHA.872@xxxxxx
> >> 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
> >>news:%23mTtl9C$IHA.1152@xxxxxx
> >>> Hi there >
> >>> I am using vbscript to collect information from web site. > {snip}
Tim.
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
searching for. Rather, it is accessed by a JavaScript function call.
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
title ...
set IEW = FindWindow("How to")
if IEW is Nothing then
wsh.echo "Window not found"
else
wsh.echo left(IEW.document.body.InnerHTML, 128)
end if
Function FindWindow(sTitle)
Dim wndw
set FindWindow = Nothing
with createobject("shell.application")
for each wndw in .windows
if instr(lcase(typename(wndw.document)), "htmldocument") > 0
then
if Instr(lcase(wndw.document.title), lcase(sTitle)) > 0 then
set FindWindow = wndw
exit function
end if
end if
next
end with
end function
HTH,
Tom Lavedas
===========