excel - VBA Getting results in another url but same window -


I am working with VBA to submit a form to a URL and submit to get results. When I submit the form with the correct values ​​and submit it through VBA, I get it in another URL, but on the same window.

The problem is that I do not know how to change the HTML reference, with this new URL.

Here's my code:

  'Internet Explorer to refer to the ongoing copy of IE dim' HTMLDocument as HTML 'in Open Internet Explorer Memory, and Go to the website IE = New Internet Explorer IE.Visible = False IE.navigate "http: // url ..." 'Wait until IE is loading page until IE.READYSTATE & lt; & Gt; READYSTATE_COMPLETE application.StatusBar = "Connecting with http: // url ..." Returns the text of the 'DoEvents Loop' HTML document Returns HTML = IE.document 'Close IE and Reset Status Bar IE = Something Not even Application.StatusBar = "" set txtArea = html.getElementsByTagName ("text field") (0) txtArea.Value = txtArea_data set formSubmit = html.getElementsByName ("submit") (1) formSubmit.Click '--- ---------- Get the results 'dim html_results' as HTMLDocument IE.navigate "http: // new_url" 'I'm not sure that I should do this like this ...' Wait IE loading page Not sure. Although IE.READYSTATE & lt; & Gt; READYSTATE_COMPLETE Application.StatusBar = "Connect with http: // NEW_URL ..." DoEvents Loop Set HTML = IE.document Dim TrResults as IHTMLElementCollection Set trResults = html.getElementsByClassName ("tr") MsgBox (trRults.Length) 'this point But, TrResults always has 0 results ...   

Do you have any ideas to help me?

Thank you!

This is a new way, and still does not work. I have used IE.Visible = True , so I can check that on the results page I have many & lt; Tr & gt; Get results. dim rowNumber Long dim txtArea_data string dim txtArea as object dim formSubmit as object dim IE InternetExplorer Dim HTML HTMLDocument set IE = New InternetExplorer IE.Visible = true IE.navigate as "http: // url ..." though what IE.READYSTATE & lt; & Gt; READYSTATE_COMPLETE application.StatusBar = "Connecting with http: // url ..." DoEvents Loop Set html = IE.document rowNumber = 4 for line number = 4 to 120 'rows. Account txtArea_data = txtArea_data & amp; Room (line number, 1). Price & amp; Chr (10) Next rowNumber set txtArea = html.getElementsByTagName ("text field") (0) txtArea.Value = txtArea_data set formSubmit = html.getElementsByName ("submit") (1) formSubmit.Click 'wait until the result while Do IE Busy: Doants: Loop '-------------' Get Results' At this point, the result page URL has changed, but on the same tab. In other code, I used IE.navigate "http: // new_url ..." but an "invalid file" message appears '-------------' I think That these new results of html can be recharged with data but nothing happens ... set html = IE.document dim trResults set IHTMLElementCollection trResults = html.getElementsByClassName ("Tr") MsgBox (trRults.Length ) 'At this point, MsgBox returns ... set html = nothing

results page looks like this:

    

Is there a problem that you can ask to help you find the problem? Thanks!

Edit

Oh God! I set the set to tr trResults = html.getElementsByTagName ("tr") trResults = html.getElementsByClassName ("tr")

Thank you for your time!

What should I do now? Edit the original question with the final solution or close the whole question?

Thank you! I do not use too many Stackoverflow to ask questions

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -