murdytherp
New Member
- Joined
- Jan 3, 2014
- Messages
- 11
Good evening,
Following a suggestion on another thread, i've been using vba with ie document to parse javascript form results
This works for single files, but when placed in a loop hangs and crashes my computer after about 70 iterations
Searching for a solution pointed me to use MSXMLHTTP and HTMLHTTP with the latter being blocked by system administrator. Following the example, I've come up with
It does not work. I tried just the "txtNiin=" & txtNiin and it still does not work. The end result is the hard coded number will be a variable and I'll parse the results, but I can't even get the hard coded number to post to the page. It does submit something and returns something strange (see oXMLhttp.responseText).
Thank you in advance for your help
Following a suggestion on another thread, i've been using vba with ie document to parse javascript form results
Rich (BB code):
Dim IE As InternetExplorer
Sub Update_Price()
Application.ScreenUpdating = False
Set IE = New InternetExplorer
Set rng = ActiveCell
IE.Visible = False
IE.Navigate "WebFLIS - Public Search"
Application.StatusBar = "Submitting"
' Wait while IE loading...
Do While (IE.Busy Or IE.readyState <> 4)
DoEvents
Loop
' **********************************************************************
' checkboxes and "clear all" ... C1,C3,C6,C4,C7,C9,C14,Submit (in order top to bottom)
IE.document.getelementbyid("txtNiin").Value = rng
IE.document.getelementbyid("btnNIIN").Click
'**********************************************************************
Do While (IE.Busy Or IE.readyState <> 4)
DoEvents
Loop
With IE.document.getelementbyid("lblItemName")
ActiveCell.Offset(0, -1).Value = .innertext
End With
With IE.document.getelementbyid("Datagrid19")
For x = 0 To .Rows.Length - 1
For y = 0 To .Rows(x).Cells.Length - 1
ActiveCell.Offset(0, 2).Value = .Rows(1).Cells(5).innertext
ActiveCell.Offset(0, 1).Value = .Rows(1).Cells(4).innertext
Next y
Next x
End With
Application.StatusBar = "Form Submitted"
Set IE = Nothing
Set NSN = Nothing
Application.ScreenUpdating = True
End Sub
This works for single files, but when placed in a loop hangs and crashes my computer after about 70 iterations
Searching for a solution pointed me to use MSXMLHTTP and HTMLHTTP with the latter being blocked by system administrator. Following the example, I've come up with
Rich (BB code):
Public Sub openWebsite()
Dim oXmlHttp As Object
Dim btNiin As String, txtNiin As String, PostData As String, C1 As String, C3 As String, C6 As String, C7 As String, C9 As String, C14 As String, url As String
Dim txtMultipleNiin As String, txtKeyword As String, txtPART As String, txtManName As String, txtManPartNum As String, txtCAGE As String
'Website Options
btnNiin = "submit"
txtNiin = "9925-01-305-3411"
txtMultipleNiin = "" '].value = "";
txtKeyword = "" '].value = "";
txtPART = "" '].value = "";
txtManName = "" '].value = "";
txtManPartNum = "" '].value = "";
txtCAGE = "" '].value = "";
C1 = "" 'type checked for checked
C3 = "" 'type checked for checked
C6 = "" 'type checked for checked
C4 = "Checked" 'Management type checked for checked
C7 = "" 'type checked for checked
C9 = "" 'Freight Data type checked for checked
C14 = "" 'type checked for checked
PostData = "txtNiin=" & txtNiin & "C1=" & C1 & "C3=" & C3 & "C6=" & C6 & "C4=" & C4 & "C7=" & C7 & "C9=" & C9 & "C14=" & C14 & "txtMultipleNiin=" & txtMultipleNiin & "txtKeyword=" & txtKeyword & "txtPART=" & txtPART & "txtManName=" & txtManName & "txtManPartNum=" & txtManPartNum & "txtCAGE=" & txtCAGE
url = "WebFLIS - Public Search"
Set oXmlHttp = CreateObject("MSXML2.XMLHTTP")
oXmlHttp.Open "Post", url, False
oXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXmlHttp.send (PostData)
Dim oHtmlObj As Object
Set oHtmlObj = CreateObject("htmlfile")
oHtmlObj.body.innerHTML = oXmlHttp.responseText
Debug.Print oXmlHttp.responseText
End Sub
It does not work. I tried just the "txtNiin=" & txtNiin and it still does not work. The end result is the hard coded number will be a variable and I'll parse the results, but I can't even get the hard coded number to post to the page. It does submit something and returns something strange (see oXMLhttp.responseText).
Thank you in advance for your help