1

haven't touched VBA in about 10 years, and just starting to use it gain to improve efficiency and accuracy at work. All I want to do is import/copy the individual value from a html5 span.

This is the HTML5 (I am hoping this is the only info you need) And i am hoping to import "FRANK

<span class="defvalue" id="GivenName">FRANK</span>

I have been able to launch IE and log into the page and get to the page that has the info I want, but I am not sure where to go from there, I tried something along the line of below, hoping it would be that easy, however this appears not to be the case. As you may see, massive amature.

ieApp.Navigate "https://example.info.com/Details/" & Range("C6")
        Do While ieApp.Busy: DoEvents: Loop
        Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
            Range("B1").Value = "Collecting Data..."

        Range("C10").Value = appIE.Document: .getElementsById ("GivenName")

Any help would be much appreciated. I was hoping to collect a select few other values from other spans on the same page also.

Thanks,

Fletch

Fletchh
  • 11
  • 1
  • Hi, I think you should look at this topic regarding [parsing HTML in VBA](http://stackoverflow.com/questions/25488687/parse-html-content-in-vba) , which should work for you. – Pierre Chevallier Aug 29 '16 at 13:29
  • 1
    `appIE.Document: .getElementsById ("GivenName")` this doesn't compile, does it? `appIE` isn't the name of the object you're using `ieApp` and the colon in the middle of the line makes `.getElementsById` an unqualified reference... – Mikegrann Aug 29 '16 at 13:41

1 Answers1

1

What you had to do was get the innerHTML value of ieApp.document.getElementById("GivenName")

the below code will do the job to get the value in GivenName id block from https://example.info.com/Details/

Dim ieApp As Object
Set ieApp = CreateObject("internetexplorer.application")

With ieApp
    .Navigate "https://example.info.com/Details/"
    .Visible = False
End With

Do While ieApp.Busy
    DoEvents
Loop

Set allRowOfData = ieApp.document.getElementById("GivenName")

Dim myValue As String
myValue = allRowOfData.innerHTML

MsgBox myValue

Set ieApp = Nothing
Arun Thomas
  • 805
  • 1
  • 12
  • 21