I'm trying to obtain the inner text from an HTML table, but the elements are returning empty:
[HTML
][/HTML]
Above is the address I am trying to grab.
This is the VBA code I am using, which it never errors out, but it states the element is empty:
I would love some help on this if possible.[TABLE="class: table table-hover"]
<thead> [TR]
[TH]NPI[/TH]
[TH]Name[/TH]
[TH]NPI Type[/TH]
[TH]Primary Practice Address[/TH]
[TH]Phone[/TH]
[TH]Primary Taxonomy[/TH]
[/TR]
</thead> <tbody> [TR]
[TD]123456[/TD]
[TD]TEST PROV [/TD]
[TD]
[/TD]
[TD]530 N STREET
SAN DIEGO, CA
12345-0004
[/TD]
[/TR]
</tbody>[/TABLE]
[HTML
][/HTML]
Above is the address I am trying to grab.
This is the VBA code I am using, which it never errors out, but it states the element is empty:
Code:
Dim IE As InternetExplorerDim aEle As HTMLDivElement
Dim Result As String
Dim y As Integer
Dim objDivs, objDivs1 As IHTMLElementCollection
Dim objAnchors, objAnchors1 As IHTMLElementCollection
Dim intCounter As Integer
Dim myElement, myElement1 As Object
Dim WB As Workbook
Dim WS As Worksheet
Dim dashpos As Long
Dim Sex As Long
Dim TitleArray As Variant
Dim doc As HTMLDocument
Set WB = ThisWorkbook
Set WS = WB.Worksheets("NPI")
'Application.ScreenUpdating = False
'On Error GoTo Handler
lrow = WS.Cells(Rows.Count, 1).End(xlUp).Row
Set IE = CreateObject("InternetExplorer.Application")
WS.Activate
'make IE browser visible
IE.Visible = True
srow = WS.Cells(Rows.Count, 2).End(xlUp).Row
CLrow = WB.Worksheets("Category").Cells(Rows.Count, 4).End(xlUp).Row
TitleArray = WB.Worksheets("Category").Range("D2", "D" & CLrow)
On Error Resume Next
For r = srow To lrow
srow = WS.Cells(Rows.Count, 2).End(xlUp).Row
'navigate IE to this web page
IE.navigate "https://test.com" & WS.Cells(r + 1, 1).Value
Set doc = IE.document
'wait here a few seconds whilte the browser is busy
Do While IE.Busy = True Or IE.readyState <> 4: DoEvents: Loop
Set elems = doc.getElementsByClassName("table table-hover").getElementsByTagName("tr")
For Each e In elems
Debug.Print Trim(e.getElementsByTagName("td")(1).innerText)
Next e
I would love some help on this if possible.[TABLE="class: table table-hover"]
<thead> [TR]
[TH]NPI[/TH]
[TH]Name[/TH]
[TH]NPI Type[/TH]
[TH]Primary Practice Address[/TH]
[TH]Phone[/TH]
[TH]Primary Taxonomy[/TH]
[/TR]
</thead> <tbody> [TR]
[TD]123456[/TD]
[TD]TEST PROV [/TD]
[TD]
[/TD]
[TD]530 N STREET
SAN DIEGO, CA
12345-0004
[/TD]
[/TR]
</tbody>[/TABLE]
Last edited by a moderator: