Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default vba: Loop to load webpage

Hi,

I'm stuck and wish it was in a loop! I'm loading a webpage, entering login
info that takes me to a homepage and then trying to navigate from there to
another page in the same site and in the same IE browser window. Problem is
I get the login info entered okay on the first page but then the program
moves too quickly, not giving the homepage time to load. I've tried

Do Until .ReadyState = 4
DoEvents
Loop

to let the homepage load but it doesn't work. I'm using Excel 2000 and I've
referenced the Internet Controls library. So...do I need to reference a
different library? Could I use OnTime and navigate to the final page in
another Sub(), but then how do I get the final page to load in the same IE
browser window? Do I need to acknowledge the address of the homepage somehow
in between?

Thanks in advance to anyone who can help...

Brian


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Loop to load webpage

readystate should work: maybe your page is framed (frame loads quickly
but subpages are slow...) ?

Can you post the rest of the [relevant] code ?

Tim.


"Brian Delaney" wrote in message
...
Hi,

I'm stuck and wish it was in a loop! I'm loading a webpage, entering
login info that takes me to a homepage and then trying to navigate
from there to another page in the same site and in the same IE
browser window. Problem is I get the login info entered okay on the
first page but then the program moves too quickly, not giving the
homepage time to load. I've tried

Do Until .ReadyState = 4
DoEvents
Loop

to let the homepage load but it doesn't work. I'm using Excel 2000
and I've referenced the Internet Controls library. So...do I need to
reference a different library? Could I use OnTime and navigate to
the final page in another Sub(), but then how do I get the final
page to load in the same IE browser window? Do I need to acknowledge
the address of the homepage somehow in between?

Thanks in advance to anyone who can help...

Brian



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Loop to load webpage

Hi Tim,

How can I determine if a page is framed? (I've been viewing the pages'
HTML code by using View Source in the IE browser window.)

Here's the whole code

Public Sub Yahoo_Finance()

' Open Internet Explorer application
Set ie = CreateObject("InternetExplorer.Application")

With ie
Visible = True
' Go to Yahoo login page
Navigate
"http://login.yahoo.com/config/login?.done=http://finance.yahoo.com&.src
=quote&.intl=us"

' Loop until the page is fully loaded
Do Until .ReadyState = 4
DoEvents
Loop

' Make the desired selections on the web page and click the submit
Button
Set ipf = ie.Document.all.Item("login")
ipf.Value = "keepithot9"
Set ipf = ie.Document.all.Item("passwd")
ipf.Value = "easier"
Set ipf = ie.Document.all.Item("login_form")
ipf.submit

' Loop until the YF homepage is fully loaded
Do Until .ReadyState = 4
DoEvents
Loop

' Go to next page within YF
Navigate "http://finance.yahoo.com/p?v&k=pf_1"

End With

End Sub


I discovered this code here on Developersdex (thread: " Web browser
question").

The weird thing is that when I first tried the code, I didn't have this
problem. I had misread the form data for the YF login page (didn't see
that it was POST method), so I substituted

Application.SendKeys "~"

for

ipf.submit

and it worked perfectly a half dozen times. Then when I tried it later
it always failed. I subsequently changed that line to ipf.submit and the
login succeeded but since then the homepage doesn't load quickly enough.
Also, when I step throught the code it works fine which is what leads me
to believe that it's the loop that's not working right.

A copule other vba-newbie questions perhaps you could help me with too?

If I have a IE browswer window already open (say, with the YF homepage
already loaded), what code do I use to activate it? AppActivate?

My ultimate goal is to copy the data from the final YF page to a
spreadsheet. What would be the code to select the contents of the page
(the whole page is fine as opposed to pinpointing tables, I can extract
the table data easily once in the spreadsheet) for copying to the
clipboard?

Finally (= really clueless), how is it that when I post directly to the
newsgroup, your reply appears on Developerdex but not the newsgroup (new
to these too)?

Hope the newbie questions aren't too annoying. Thanks very much for any
help you can offer.

Brian

*** Sent via Developersdex http://www.developersdex.com ***
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I set up a hyperlink to a webpage? D. Eley Excel Discussion (Misc queries) 1 February 15th 06 03:02 AM
Loop Function unable to loop Junior728 Excel Programming 1 July 28th 05 10:23 AM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
Importing text from webpage into excel and then loop? Sam Excel Programming 0 August 22nd 04 01:10 AM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 11:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"