Issue with time taken to load a page in automated int exp.

FamousSam

New Member
Joined
Feb 10, 2004
Messages
5
Hi, I'm writing VBA code that extracts text from news items and inserts it into an Excel ssheet.
Often I find that the macro does not find the relevant news because the page is still loading and the VBA code that is supposed to prevent the macro moving on until the load is complete is having trouble working properly. Is there any better way of ensuring the internet explorer page is fully loaded than to put a massive for next loop in?

The code that is not working well is shown below.

'###################################################
Do While ie.readyState <> READYSTATE_COMPLETE
Loop
Do While Left(ie.StatusText, 4) = "Open"
Loop
For x = 1 To 1000000000
Next x
'###################################################

Thanks in advance.

Famous.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
Re: Issue with time taken to load a page in automated int ex

Cannot really tell anything from your partial code. Here is a working example :-

Code:
Sub test()
    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.navigate "http://www.google.com"
    Do Until IE.readyState = 4
        DoEvents
    Loop
    MsgBox ("Done")
End Sub

From experience DoEvents doesn't always solve problems, so if you have further ones I suggest you come back with a new post. Many do not read 'answered' ones.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,327
Messages
5,769,460
Members
425,550
Latest member
Bonebeast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top