1

Using the method below, ie brings all myLink into my excel cells the way it is in the web page -

result = ie.document.body.innerHTML
Set html = CreateObject("htmlfile")
html.body.innerHTML = result
Set myLinks = html.getElementsByTagName("A")

For Each myLink In myLinks
Sheet1.Cells(i, "A").Value = myLink

Therefore I have to write a few conditional Replace statements to replace some left characters in some myLink with http://www.
But when I use the method below, ie brings every myLink into my excel cells with the http://www.. I do not have to deal with any Replace statements -

Set myLinks = ie.document.getElementsByTagName("A")

For Each myLink In myLinks
Sheet1.Cells(i, "A").Value = myLink

Now xmlHttp is a lot faster and I would like to use it, but it too brings the myLink as is in the web page with this method -

Set html = CreateObject("htmlfile")
html.body.innerHTML = xmlHttp.ResponseText
Set myLinks = html.getElementsByTagName("A")

For Each myLink In myLinks
Sheet1.Cells(i, "A").Value = myLink

I tried the following but it doesn't work -

Set myLinks = xmlHttp.ResponseText.getElementsByTagName("A")

For Each myLink In myLinks
Sheet1.Cells(i, "A").Value = myLink

Still looking around but haven't found anything yet to bypass the html object to Set myLinks. Hence my question to elite members - is there a way to bypass the html object or is that a must for xmlHttp object? Appreciate any help or answer.

Sandy
  • 59
  • 2
  • 13
  • 2
    See brettdj's answer [here](http://stackoverflow.com/questions/8798260/html-parsing-of-cricinfo-scorecards) on how to work with `xmlhttp`object – Siddharth Rout Dec 16 '13 at 03:44
  • @SiddharthRout Hi, thanks for the link:). xmlHttp is actually working for me. Have updated my question to shed more light on why I am trying to bypass html object for what I am doing. – Sandy Dec 17 '13 at 19:09
  • Using html object...the code which you have posted is perfect `Set html = CreateObject("htmlfile") html.body.innerHTML = xmlHttp.ResponseText Set myLinks = html.getElementsByTagName("A") For Each myLink In myLinks Sheet1.Cells(i, "A").Value = myLink` . You can add a breakpoint to `myLink` variable and look in its property like `myLink.innerText` or `myLink.innerHTML` – Santosh Dec 24 '13 at 09:56
  • @Santosh thanks for the response, but my question was different. I am asking - just like we can (and as I have shown), use ie with or w/o html object, can we use xmlhttp with or w/o html object - we know (as I in my question and you in your response have shown) we can use xmlhttp with html object, but can we use it w/o the html object? If yes how? Have explained in my question the advantage of using ie w/o html object, hence the effort of being able to do the same in xmlhttp. – Sandy Dec 25 '13 at 18:02
  • @Santosh FYI, tried declaring myLinks as a String and then in my code, `myLinks = xmlHttp.ResponseText.getElementsByTagName("A")` but it resulted fetching incomplete copy of the web page source in one cell - maybe cell limitation of my xl2003? – Sandy Dec 25 '13 at 18:07

0 Answers0