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 fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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.
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,871
Members
449,054
Latest member
juliecooper255

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
Back
Top