• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

fill web

mohadin

Active Member
Hi Gentlemen
I get this pice of code for the net
it works ok with internet explorer

Code:
Sub GetHTMLDocument()

  Dim IE As New SHDocVw.InternetExplorer
  Dim HTMLDoc As MSHTML.HTMLDocument
  Dim HTMLInput As MSHTML.IHTMLElement
  Dim HTMLButtons As MSHTML.IHTMLElementCollection
  Dim HTMLButton As MSHTML.IHTMLElement
 
  IE.Visible = True
  IE.navigate "wiseowl.co.uk"
 
  Do While IE.readyState <> READYSTATE_COMPLETE
  Loop
 
  Set HTMLDoc = IE.document
  Set HTMLInput = HTMLDoc.getElementById("what")
  Debug.Print HTMLInput.Value
  HTMLInput.Value = "Excel VBA"
 
  Set HTMLButtons = HTMLDoc.getElementsByTagName("button")
 
'  For Each HTMLButton In HTMLButtons
'  Debug.Print HTMLButton.className, HTMLButton.tagName, HTMLButton.ID, HTMLButton.innerText
'  Next HTMLButton
 
  HTMLButtons(0).Click
 
End Sub

Because I need to use it with Firefox browser I did some modification to it and I get this below code but I'm not able to have it working.
The line in (HTMLInput.Value = "Excel VBA") is wrong I could not fix it.
may I get any help with this.
Thank you very much

Code:
Sub test()

Dim HTMLInput As MSHTML.HTMLInputElement
Dim XMLPage As New MSXML2.XMLHTTP60
Dim HTMLDoc As New MSHTML.HTMLDocument

XMLPage.Open "GET", "https://www.wiseowl.co.uk/", False
XMLPage.send
HTMLDoc.body.innerHTML = XMLPage.responseText
'Debug.Print HTMLDoc.DocumentElement.innerHTML
Debug.Print HTMLDoc.body.innerHTML
HTMLDoc.body.innerHTML = XMLPage.responseText
Set HTMLInput = HTMLDoc.getElementById("what")

HTMLInput.Value = "Excel VBA"


End Sub
 
Last edited by a moderator:
Hi !

This kind of VBA code works only with Internet Explorer !

For other webbrowser, see for example selenium add-on
and its forum (as it is not standard VBA) …
 
Thank you Mr.Mark
Well, I agreed with you, still the second code refuse to work even with IE!!!
There is some bug some where?
I could not fix it.
Please help
 
Back
Top