Results 1 to 1 of 1

Wait for Specific Text to Load Using VBA Object "MSXML2.XMLHTTP.6.0" or Similar

Threaded View

  1. #1
    Registered User
    Join Date
    01-07-2020
    Location
    Poland
    MS-Off Ver
    2017
    Posts
    1

    Wait for Specific Text to Load Using VBA Object "MSXML2.XMLHTTP.6.0" or Similar

    I have the following code using Internet Explorer which allows the page to load until the word "Fair Value" appears in the final HTML (which I then want to extract):
    Dim t As Date,
    Const MAX_WAIT_SEC As Long = 3 '<==Adjust wait time
    
    myFile = ActiveWorkbook.Path & "\Downloads\FinBox.html"
    If FileExists(myFile) Then Kill myFile
    
    
    Set oIE = New InternetExplorer
    myUrl="h t t p s : / / finbox.com/NASDAQGS:AMZN/models/dcf-growth-exit-10yr"
    oIE.navigate myUrl
    oIE.Visible = True
    
    Do
    Loop Until oIE.readyState = READYSTATE_COMPLETE
    oIE.Refresh
    
    While oIE.Busy Or oIE.readyState < 4: DoEvents: Wend
    t = Timer
    Do
        DoEvents
        On Error Resume Next
        HTMLDoc.Body.innerHTML = oIE.document.Body.innerHTML
        sPageHTML = HTMLDoc.Body.innerHTML
        If InStr(LCase(sPageHTML), "fair value") > 0 Then ftextFound = True
        If Timer - t > MAX_WAIT_SEC Then Exit Do
        On Error GoTo 0
    Loop While ftextFound = False
    
    If ftextFound = True Then
        fileNo = FreeFile
        Open myFile For Output As #fileNo
        Print #fileNo, sPageHTML
        Close #fileNo
    End If
    Since I believe that Internet Explorer will no longer be supported in Windows 11, can someone provide code that will mimic this functionality using "MSXML2.XMLHTTP.6.0"or similar in VBA?

    I do have Selenium installed, so similar code for that would also be acceptable.

    The idea is that it is a dynamic page which takes a few seconds to completely load, so just getting the .responseText is not sufficient.

    Thanks.
    Last edited by davesexcel; 11-11-2021 at 10:52 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. MSXML2.XMLHTTP - Failed to Load Chunk...
    By Exequiel3k in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-29-2020, 10:18 PM
  2. [SOLVED] Disable "Could not load object because it is not available on this machine" Pop-Up.
    By kermit_d_frog in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-10-2019, 10:59 AM
  3. transition from using IE to MSXML2.XMLHTTP"
    By Exequiel3k in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-29-2019, 12:27 PM
  4. Problem with consistent "Application.Wait (Now + TimeValue("0:00:10"))"
    By JimmyWilliams in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 02-09-2018, 08:20 PM
  5. Why does this "wait for page to load" fail?
    By hgtenn in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-04-2014, 01:54 PM
  6. CreateObject("MSXML2.XMLHTTP") put CCS tables into excel sheet ?
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-27-2013, 07:35 PM
  7. How does the MSXML2.XMLHTTP object connect to the same session
    By paranidharan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-23-2013, 04:38 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1