Using VBA after Internet Exploer goes away, how to receive web page text

Michael Kaplan 6 Reputation points
2022-05-04T23:58:57.207+00:00

After IE goes away I still need using VBA to be able to request a web page and receive the retuned contents.
Here is a test call i put together for this forum:
The main thing is to be able to use some browser after IE goes away and to be able to receive the output from the website.
Thanks ahead of time for any help.

  • Mike -

Sub testcall()
Dim http As Object
Dim JSON As Object
Dim IE As Object
Dim IE_URL As String

Set IE = CreateObject("InternetExplorer.Application")
With IE
    .Visible = True
    IE_URL = "http://www.vbaexpress.com/"
    .Navigate IE_URL, 14, "_self", Null ', header2
    Do Until .readyState = 4: Application.Wait (Now + TimeValue("0:00:01")): Loop
    Debug.Print .document.body.innerText
  '  Set oJson = ParseJSONx(.document.body.innerText)
End With

End Sub

Office Visual Basic for Applications
Office Visual Basic for Applications
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Visual Basic for Applications: An implementation of Visual Basic that is built into Microsoft products.
1,506 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Viorel 122.3K Reputation points
    2022-05-05T19:34:16.697+00:00

    Check an alternative:

    Dim x
    Set x = CreateObject("MSXML2.XMLHTTP")
    
    x.Open "GET", "http://. . . .", False
    x.Send
    
    Dim result As String
    result = x.responseText
    
    0 comments No comments

  2. Pro Gamer 0 Reputation points
    2023-03-23T19:31:00.79+00:00

    This gonna work;

    Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
    
    IE.Navigate "
    IE.Visible = True
    
    'Wait til DOM is ready
    Do Until IE.ReadyState = 4 : Loop
    
    If IsObject(IE.Document.GetElementById("nav-tags")) Then
        IE.Document.GetElementById("nav-tags").Click()
    End If
    
    Set IE = Nothing
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.