Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - How to get the content of a newly created instance of IE

Reply
 
Old 08-11-2008   #1 (permalink)
jason


 
 

How to get the content of a newly created instance of IE

Hi there

I am using vbscript to collect information from web site.

First I created an IE object and navigated it to
"http://www.pennyweight.com.au", I have used a function to ensure
IE.Document.ReadyState = "complete".
Secondly, I used codes to find the url of the "Order" link
Thirdly, I used IE to navigate to this new order page
Unfortunately, the content returned by the Document object is the source
codes of page "http://www.pennyweight.com.au" instead of "Order" page. But I
do want is the content of "Order" page.

Hereafter are the codes I used:

option explicit

dim accessURL
dim IE
dim a

set IE = CreateObject("InternetExplorer.Application")
accessURL = "http://www.pennyweight.com.au"
IE.navigate(accessURL)
wscript.sleep 5000 ' actually I used a function to ensure
IE.Document.ReadyState = "complete"

for each a in IE.Document.GetElementsByTagName("a")
if Lcase(a.innerText) = "order" then
IE.navigate(a.href)
wscript.sleep 5000 ' actually I used a function to ensure
IE.Document.ReadyState = "complete"
exit for
end if
Next

wscript.echo IE.Document.GetElementsbyTagName("html")(0).innerHTML

Can any one help me?

Many thanks in advance!

Jason



My System SpecsSystem Spec
Old 08-12-2008   #2 (permalink)
Joe Fawcett


 
 

Re: How to get the content of a newly created instance of IE



"jason" <atechmark@xxxxxx> wrote in message
news:#mTtl9C$IHA.1152@xxxxxx
Quote:

> Hi there
>
> I am using vbscript to collect information from web site.
>
> First I created an IE object and navigated it to
> "http://www.pennyweight.com.au", I have used a function to ensure
> IE.Document.ReadyState = "complete".
> Secondly, I used codes to find the url of the "Order" link
> Thirdly, I used IE to navigate to this new order page
> Unfortunately, the content returned by the Document object is the source
> codes of page "http://www.pennyweight.com.au" instead of "Order" page. But
> I do want is the content of "Order" page.
>
> Hereafter are the codes I used:
>
> option explicit
>
> dim accessURL
> dim IE
> dim a
>
> set IE = CreateObject("InternetExplorer.Application")
> accessURL = "http://www.pennyweight.com.au"
> IE.navigate(accessURL)
> wscript.sleep 5000 ' actually I used a function to ensure
> IE.Document.ReadyState = "complete"
>
> for each a in IE.Document.GetElementsByTagName("a")
> if Lcase(a.innerText) = "order" then
> IE.navigate(a.href)
> wscript.sleep 5000 ' actually I used a function to ensure
> IE.Document.ReadyState = "complete"
> exit for
> end if
> Next
>
> wscript.echo IE.Document.GetElementsbyTagName("html")(0).innerHTML
>
> Can any one help me?
>
> Many thanks in advance!
>
> Jason
>
>
I'd check the URL of the new page. If it's still the first URL then it maybe
a redirection happens because of lack of a cookie, not being signed in etc.

--

Joe Fawcett (MVP - XML)
http://joe.fawcett.name

My System SpecsSystem Spec
Old 08-12-2008   #3 (permalink)
Tim Williams


 
 

Re: How to get the content of a newly created instance of IE

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)

Tim

"jason" <atechmark@xxxxxx> wrote in message
news:%23mTtl9C$IHA.1152@xxxxxx
Quote:

> Hi there
>
> I am using vbscript to collect information from web site.
>
> First I created an IE object and navigated it to
> "http://www.pennyweight.com.au", I have used a function to ensure
> IE.Document.ReadyState = "complete".
> Secondly, I used codes to find the url of the "Order" link
> Thirdly, I used IE to navigate to this new order page
> Unfortunately, the content returned by the Document object is the source
> codes of page "http://www.pennyweight.com.au" instead of "Order" page. But
> I do want is the content of "Order" page.
>
> Hereafter are the codes I used:
>
> option explicit
>
> dim accessURL
> dim IE
> dim a
>
> set IE = CreateObject("InternetExplorer.Application")
> accessURL = "http://www.pennyweight.com.au"
> IE.navigate(accessURL)
> wscript.sleep 5000 ' actually I used a function to ensure
> IE.Document.ReadyState = "complete"
>
> for each a in IE.Document.GetElementsByTagName("a")
> if Lcase(a.innerText) = "order" then
> IE.navigate(a.href)
> wscript.sleep 5000 ' actually I used a function to ensure
> IE.Document.ReadyState = "complete"
> exit for
> end if
> Next
>
> wscript.echo IE.Document.GetElementsbyTagName("html")(0).innerHTML
>
> Can any one help me?
>
> Many thanks in advance!
>
> Jason
>
>

My System SpecsSystem Spec
Old 08-14-2008   #4 (permalink)
jason


 
 

Re: How to get the content of a newly created instance of IE

Hi Tim,

Thanks for your help!

I set IE visible but the content of IE's Document was not what I wanted.
Also I appended one more line of code IE.quit and only the IE displaying the
content of http://www.pennyweight.com.au quit. The new IE displaying "Order"
page is still there but seems I have no way to get its Document object.

Attached is the whole code I used.

***********************************************
option explicit

dim accessURL
dim IE
dim a
dim i
dim txt

set IE = CreateObject("InternetExplorer.Application")
IE.visible = true
accessURL = "http://www.pennyweight.com.au"

IE.navigate(accessURL)

'Ensure the readystate of Document is complete
i = 0
do until IE.ReadyState = 4
Wscript.Sleep 100
i = i + 1
if i > 50 then exit do
loop

i = 0
if IE.ReadyState = 4 then
do until IE.Document.ReadyState = "complete"
Wscript.Sleep 100
i = i + 1
if i > 50 then exit do
loop
end if

'Get the link of order page
for each a in IE.Document.GetElementsByTagName("a")
if Lcase(Trim(a.innerText)) = "order" then
txt = a.href
exit for
end if
next


IE.navigate(txt)
i = 0
do until IE.ReadyState = 4
Wscript.Sleep 100
i = i + 1
if i > 50 then exit do
loop

i = 0
if IE.ReadyState = 4 then
do until IE.Document.ReadyState = "complete"
Wscript.Sleep 100
i = i + 1
if i > 50 then exit do
loop
end if

wscript.echo IE.Document.GetElementsbyTagName("html")(0).innerHTML
IE.quit
*********************************************************

Best regards

Jason



"Tim Williams" <timjwilliams at gmail dot com> wrote in message
news:OdDUSTE$IHA.872@xxxxxx
Quote:

> 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)
>
> Tim
>
> "jason" <atechmark@xxxxxx> wrote in message
> news:%23mTtl9C$IHA.1152@xxxxxx
Quote:

>> Hi there
>>
>> I am using vbscript to collect information from web site.
>>
>> First I created an IE object and navigated it to
>> "http://www.pennyweight.com.au", I have used a function to ensure
>> IE.Document.ReadyState = "complete".
>> Secondly, I used codes to find the url of the "Order" link
>> Thirdly, I used IE to navigate to this new order page
>> Unfortunately, the content returned by the Document object is the source
>> codes of page "http://www.pennyweight.com.au" instead of "Order" page.
>> But I do want is the content of "Order" page.
>>
>> Hereafter are the codes I used:
>>
>> option explicit
>>
>> dim accessURL
>> dim IE
>> dim a
>>
>> set IE = CreateObject("InternetExplorer.Application")
>> accessURL = "http://www.pennyweight.com.au"
>> IE.navigate(accessURL)
>> wscript.sleep 5000 ' actually I used a function to ensure
>> IE.Document.ReadyState = "complete"
>>
>> for each a in IE.Document.GetElementsByTagName("a")
>> if Lcase(a.innerText) = "order" then
>> IE.navigate(a.href)
>> wscript.sleep 5000 ' actually I used a function to ensure
>> IE.Document.ReadyState = "complete"
>> exit for
>> end if
>> Next
>>
>> wscript.echo IE.Document.GetElementsbyTagName("html")(0).innerHTML
>>
>> Can any one help me?
>>
>> Many thanks in advance!
>>
>> Jason
>>
>>
>
>

My System SpecsSystem Spec
Old 08-14-2008   #5 (permalink)
jason


 
 

Re: How to get the content of a newly created instance of IE

Hi Joe,

I found the URL of the new page (http://www.pennyweight.com.au/order.html)
is different from the original. So I don'yt think it is a redirection issue.

Many thanks

Jason

"Joe Fawcett" <joefawcett@xxxxxx> wrote in message
news:%23ZrM0SE$IHA.1180@xxxxxx
Quote:

>
>
> "jason" <atechmark@xxxxxx> wrote in message
> news:#mTtl9C$IHA.1152@xxxxxx
Quote:

>> Hi there
>>
>> I am using vbscript to collect information from web site.
>>
>> First I created an IE object and navigated it to
>> "http://www.pennyweight.com.au", I have used a function to ensure
>> IE.Document.ReadyState = "complete".
>> Secondly, I used codes to find the url of the "Order" link
>> Thirdly, I used IE to navigate to this new order page
>> Unfortunately, the content returned by the Document object is the source
>> codes of page "http://www.pennyweight.com.au" instead of "Order" page.
>> But I do want is the content of "Order" page.
>>
>> Hereafter are the codes I used:
>>
>> option explicit
>>
>> dim accessURL
>> dim IE
>> dim a
>>
>> set IE = CreateObject("InternetExplorer.Application")
>> accessURL = "http://www.pennyweight.com.au"
>> IE.navigate(accessURL)
>> wscript.sleep 5000 ' actually I used a function to ensure
>> IE.Document.ReadyState = "complete"
>>
>> for each a in IE.Document.GetElementsByTagName("a")
>> if Lcase(a.innerText) = "order" then
>> IE.navigate(a.href)
>> wscript.sleep 5000 ' actually I used a function to ensure
>> IE.Document.ReadyState = "complete"
>> exit for
>> end if
>> Next
>>
>> wscript.echo IE.Document.GetElementsbyTagName("html")(0).innerHTML
>>
>> Can any one help me?
>>
>> Many thanks in advance!
>>
>> Jason
>>
>>
> I'd check the URL of the new page. If it's still the first URL then it
> maybe a redirection happens because of lack of a cookie, not being signed
> in etc.
>
> --
>
> Joe Fawcett (MVP - XML)
> http://joe.fawcett.name

My System SpecsSystem Spec
Old 08-14-2008   #6 (permalink)
mayayana


 
 

Re: How to get the content of a newly created instance of IE

i = 0
do until IE.ReadyState = 4
Wscript.Sleep 100
i = i + 1
if i > 50 then exit do
loop


I don't know whether this is the problem,
but I don't see the point of the count to 50.
You've designed it so that your script fails if
the page takes more than 5 seconds to load.



My System SpecsSystem Spec
Old 08-14-2008   #7 (permalink)
Paul Randall


 
 

Re: How to get the content of a newly created instance of IE

Hi, Jason
If you stick a message box statement in to pause the script before
navigating to the order page, you can mouse around the web page and get some
ideas of what is happening. If you hold the mouse over the order link, IE
will show the HREF in the status bar (if you have status bar being
displayed). It is not an ordinary HREF; it is a reference to a JScript
routine called order. This routine pops up a new window, and displays
http://www.pennyweight.com.au/order.html.
Perhaps your script can be modified to extract the order.html link and
navigate there and then play with its HTML.

-Paul Randall

"jason" <atechmark@xxxxxx> wrote in message
news:OxB2rbm$IHA.3380@xxxxxx
Quote:

> Hi Tim,
>
> Thanks for your help!
>
> I set IE visible but the content of IE's Document was not what I wanted.
> Also I appended one more line of code IE.quit and only the IE displaying
> the content of http://www.pennyweight.com.au quit. The new IE displaying
> "Order" page is still there but seems I have no way to get its Document
> object.
>
> Attached is the whole code I used.
>
> ***********************************************
> option explicit
>
> dim accessURL
> dim IE
> dim a
> dim i
> dim txt
>
> set IE = CreateObject("InternetExplorer.Application")
> IE.visible = true
> accessURL = "http://www.pennyweight.com.au"
>
> IE.navigate(accessURL)
>
> 'Ensure the readystate of Document is complete
> i = 0
> do until IE.ReadyState = 4
> Wscript.Sleep 100
> i = i + 1
> if i > 50 then exit do
> loop
>
> i = 0
> if IE.ReadyState = 4 then
> do until IE.Document.ReadyState = "complete"
> Wscript.Sleep 100
> i = i + 1
> if i > 50 then exit do
> loop
> end if
>
> 'Get the link of order page
> for each a in IE.Document.GetElementsByTagName("a")
> if Lcase(Trim(a.innerText)) = "order" then
> txt = a.href
> exit for
> end if
> next
>
>
> IE.navigate(txt)
> i = 0
> do until IE.ReadyState = 4
> Wscript.Sleep 100
> i = i + 1
> if i > 50 then exit do
> loop
>
> i = 0
> if IE.ReadyState = 4 then
> do until IE.Document.ReadyState = "complete"
> Wscript.Sleep 100
> i = i + 1
> if i > 50 then exit do
> loop
> end if
>
> wscript.echo IE.Document.GetElementsbyTagName("html")(0).innerHTML
> IE.quit
> *********************************************************
>
> Best regards
>
> Jason
>
>
>
> "Tim Williams" <timjwilliams at gmail dot com> wrote in message
> news:OdDUSTE$IHA.872@xxxxxx
Quote:

>> 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)
>>
>> Tim
>>
>> "jason" <atechmark@xxxxxx> wrote in message
>> news:%23mTtl9C$IHA.1152@xxxxxx
Quote:

>>> Hi there
>>>
>>> I am using vbscript to collect information from web site.
>>>
>>> First I created an IE object and navigated it to
>>> "http://www.pennyweight.com.au", I have used a function to ensure
>>> IE.Document.ReadyState = "complete".
>>> Secondly, I used codes to find the url of the "Order" link
>>> Thirdly, I used IE to navigate to this new order page
>>> Unfortunately, the content returned by the Document object is the source
>>> codes of page "http://www.pennyweight.com.au" instead of "Order" page.
>>> But I do want is the content of "Order" page.
>>>
>>> Hereafter are the codes I used:
>>>
>>> option explicit
>>>
>>> dim accessURL
>>> dim IE
>>> dim a
>>>
>>> set IE = CreateObject("InternetExplorer.Application")
>>> accessURL = "http://www.pennyweight.com.au"
>>> IE.navigate(accessURL)
>>> wscript.sleep 5000 ' actually I used a function to ensure
>>> IE.Document.ReadyState = "complete"
>>>
>>> for each a in IE.Document.GetElementsByTagName("a")
>>> if Lcase(a.innerText) = "order" then
>>> IE.navigate(a.href)
>>> wscript.sleep 5000 ' actually I used a function to ensure
>>> IE.Document.ReadyState = "complete"
>>> exit for
>>> end if
>>> Next
>>>
>>> wscript.echo IE.Document.GetElementsbyTagName("html")(0).innerHTML
>>>
>>> Can any one help me?
>>>
>>> Many thanks in advance!
>>>
>>> Jason
>>>
>>>
>>
>>
>
>

My System SpecsSystem Spec
Old 08-15-2008   #8 (permalink)
Tim Williams


 
 

Re: How to get the content of a newly created instance of IE

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" <atechmark@xxxxxx> wrote in message
news:OxB2rbm$IHA.3380@xxxxxx
Quote:

> Hi Tim,
>
> Thanks for your help!
>
> I set IE visible but the content of IE's Document was not what I wanted.
> Also I appended one more line of code IE.quit and only the IE displaying
> the content of http://www.pennyweight.com.au quit. The new IE displaying
> "Order" page is still there but seems I have no way to get its Document
> object.
>
> Attached is the whole code I used.
>
> ***********************************************
> option explicit
>
> dim accessURL
> dim IE
> dim a
> dim i
> dim txt
>
> set IE = CreateObject("InternetExplorer.Application")
> IE.visible = true
> accessURL = "http://www.pennyweight.com.au"
>
> IE.navigate(accessURL)
>
> 'Ensure the readystate of Document is complete
> i = 0
> do until IE.ReadyState = 4
> Wscript.Sleep 100
> i = i + 1
> if i > 50 then exit do
> loop
>
> i = 0
> if IE.ReadyState = 4 then
> do until IE.Document.ReadyState = "complete"
> Wscript.Sleep 100
> i = i + 1
> if i > 50 then exit do
> loop
> end if
>
> 'Get the link of order page
> for each a in IE.Document.GetElementsByTagName("a")
> if Lcase(Trim(a.innerText)) = "order" then
> txt = a.href
> exit for
> end if
> next
>
>
> IE.navigate(txt)
> i = 0
> do until IE.ReadyState = 4
> Wscript.Sleep 100
> i = i + 1
> if i > 50 then exit do
> loop
>
> i = 0
> if IE.ReadyState = 4 then
> do until IE.Document.ReadyState = "complete"
> Wscript.Sleep 100
> i = i + 1
> if i > 50 then exit do
> loop
> end if
>
> wscript.echo IE.Document.GetElementsbyTagName("html")(0).innerHTML
> IE.quit
> *********************************************************
>
> Best regards
>
> Jason
>
>
>
> "Tim Williams" <timjwilliams at gmail dot com> wrote in message
> news:OdDUSTE$IHA.872@xxxxxx
Quote:

>> 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)
>>
>> Tim
>>
>> "jason" <atechmark@xxxxxx> wrote in message
>> news:%23mTtl9C$IHA.1152@xxxxxx
Quote:

>>> Hi there
>>>
>>> I am using vbscript to collect information from web site.
>>>
>>> First I created an IE object and navigated it to
>>> "http://www.pennyweight.com.au", I have used a function to ensure
>>> IE.Document.ReadyState = "complete".
>>> Secondly, I used codes to find the url of the "Order" link
>>> Thirdly, I used IE to navigate to this new order page
>>> Unfortunately, the content returned by the Document object is the source
>>> codes of page "http://www.pennyweight.com.au" instead of "Order" page.
>>> But I do want is the content of "Order" page.
>>>
>>> Hereafter are the codes I used:
>>>
>>> option explicit
>>>
>>> dim accessURL
>>> dim IE
>>> dim a
>>>
>>> set IE = CreateObject("InternetExplorer.Application")
>>> accessURL = "http://www.pennyweight.com.au"
>>> IE.navigate(accessURL)
>>> wscript.sleep 5000 ' actually I used a function to ensure
>>> IE.Document.ReadyState = "complete"
>>>
>>> for each a in IE.Document.GetElementsByTagName("a")
>>> if Lcase(a.innerText) = "order" then
>>> IE.navigate(a.href)
>>> wscript.sleep 5000 ' actually I used a function to ensure
>>> IE.Document.ReadyState = "complete"
>>> exit for
>>> end if
>>> Next
>>>
>>> wscript.echo IE.Document.GetElementsbyTagName("html")(0).innerHTML
>>>
>>> Can any one help me?
>>>
>>> Many thanks in advance!
>>>
>>> Jason
>>>
>>>
>>
>>
>
>

My System SpecsSystem Spec
Old 08-15-2008   #9 (permalink)
Tom Lavedas


 
 

Re: How to get the content of a newly created instance of IE

On Aug 15, 1:23*am, "Tim Williams" <timjwilliams at gmail dot com>
wrote:
Quote:

> Here's a function which will return a reference to an IE window which hasa
> 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}
Quote:
Quote:

> > "Tim Williams" <timjwilliams at gmail dot com> wrote in message
> >news:OdDUSTE$IHA.872@xxxxxx
Quote:

> >> 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 ?
>
Quote:
Quote:

> >> Might help to show the actual code you used (ie. include your function
> >> used to ensure page is fully loaded)
>
Quote:
Quote:

> >> Tim
>
Quote:
Quote:

> >> "jason" <atechm...@xxxxxx> wrote in message
> >>news:%23mTtl9C$IHA.1152@xxxxxx
> >>> Hi there
>
Quote:
Quote:

> >>> 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
===========
My System SpecsSystem Spec
Old 08-17-2008   #10 (permalink)
jason


 
 

Re: How to get the content of a newly created instance of IE

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:
Quote:

> 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}
Quote:
Quote:

> > "Tim Williams" <timjwilliams at gmail dot com> wrote in message
> >news:OdDUSTE$IHA.872@xxxxxx
Quote:

> >> 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 ?
>
Quote:
Quote:

> >> Might help to show the actual code you used (ie. include your function
> >> used to ensure page is fully loaded)
>
Quote:
Quote:

> >> Tim
>
Quote:
Quote:

> >> "jason" <atechm...@xxxxxx> wrote in message
> >>news:%23mTtl9C$IHA.1152@xxxxxx
> >>> Hi there
>
Quote:
Quote:

> >>> 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
===========


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Detect newly created computeraccounts in AD VB Script
Unable to login with newly created accounts Vista account administration
Newly created files protected from further access Vista General
Problem logging in with newly created user Vista account administration
not able to format newly created shrink volume Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46