(Solved) – VBA Javascript Pop-Up Window

  • by
(solved)-–-vba-javascript-pop-up-window

I am trying to get some data from a website but the HTML that needs parsing is quite complex to my level and knowledge, however, the website has a nice feature he will arrange that Data in a table. The issue is that the creation of that table is something like Table Format which pops a new chrome window. I have tried the Event Listeners in Chrome’s developer tools but no success. Is there any way to get that table?
So far I have the following code:

Option Explicit 
Public Sub IndianMoU()

    Dim strPost As String, d As String, s As String, startDate As String, endDate As String
    Dim http As Object

    startDate = "01.08.2019" 'Replace(UserForm1.TextBox1, "https://stackoverflow.com/", ".")
    endDate = "31.08.2019" '"Replace(UserForm1.TextBox2, "https://stackoverflow.com/", ".")

    Const Boundary As String = "----WebKitFormBoundary11XcIMf4gNidMvY2"
    Set http = CreateObject("MSXML2.XMLHTTP")
    'Get authentication ticket:

    'Build source form for login
    d = "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""flag1""" & vbCrLf & vbCrLf
    d = d & "0"
    d = d & vbCrLf & "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""HidFlag""" & vbCrLf & vbCrLf
    d = d & "Agreed"
    d = d & vbCrLf & "--" & Boundary & "--" & vbCrLf

    With http
        .Open "POST", "http://www.iomou.org/php/InspData.php", False
        .setRequestHeader "Content-Type", "multipart/form-data; boundary=----WebKitFormBoundary11XcIMf4gNidMvY2"
        .send d
        's = .responseText
    End With

    'Build source form for inpsections
    d = "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""FindInspAction""" & vbCrLf & vbCrLf
    d = d & "Find"
    d = d & vbCrLf & "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""StartOffset""" & vbCrLf & vbCrLf
    d = d & "1"
    d = d & vbCrLf & "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""flag1""" & vbCrLf & vbCrLf
    d = d & "0"
    d = d & vbCrLf & "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""txtStartDate""" & vbCrLf & vbCrLf
    d = d & startDate
    d = d & vbCrLf & "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""txtEndDate""" & vbCrLf & vbCrLf
    d = d & endDate
    d = d & vbCrLf & "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""opt_txtISC""" & vbCrLf & vbCrLf
    d = d & "I"
    d = d & vbCrLf & "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""txtISC""" & vbCrLf & vbCrLf
    d = d & ""
    d = d & vbCrLf & "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""opt_lstFCS""" & vbCrLf & vbCrLf
    d = d & "F"
    d = d & vbCrLf & "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""lstFCS""" & vbCrLf & vbCrLf
    d = d & "PT"
    d = d & vbCrLf & "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""chkDet""" & vbCrLf & vbCrLf
    d = d & "All"
    d = d & vbCrLf & "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""InspType""" & vbCrLf & vbCrLf
    d = d & "All"
    d = d & vbCrLf & "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""lstAuth""" & vbCrLf & vbCrLf
    d = d & "000"
    d = d & vbCrLf & "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""SortOrder""" & vbCrLf & vbCrLf
    d = d & "NoSort"
    d = d & vbCrLf & "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""AscDsc""" & vbCrLf & vbCrLf
    d = d & "Desc"
    d = d & vbCrLf & "--" & Boundary & vbCrLf
    d = d & "Content-Disposition: form-data; name=""lstLimit""" & vbCrLf & vbCrLf
    d = d & "600"
    d = d & vbCrLf & "--" & Boundary & "--" & vbCrLf

    With http
        .Open "POST", "http://www.iomou.org/php/InspData.php", False
        .setRequestHeader "Content-Type", "multipart/form-data; boundary=----WebKitFormBoundary11XcIMf4gNidMvY2"
        .send d
        s = .responseText
    End With
    Debug.Print s  
End Sub

Thank you in advance.
Eduardo

Leave a Reply

Your email address will not be published. Required fields are marked *