Table scraping Excel VBA - html

I need help scraping the tags onto my excel from an internal company website.
This is the source code.
<br />
<span class="RptTitle"><input id="chkPromisDataLog" type="checkbox" name="chkPromisDataLog" checked="checked" onclick="showOnOffPromisLog();" /><label for="chkPromisDataLog">Promis Processing data log [83508442.1].</label></span>
<div id="divPromisDataLog" style="display: none;">
<table id="tblPromisDataLog" cellspacing="0" cellpadding="0" width="100%" border="0" class="table">
<tr>
<td width="60%"></td>
<td>
<a class="textnormal" href="javascript:popwnd=window.open('../Tools/ExportExcel.aspx?KEY=LOT_GEN_PROMIS','popwnd','status=no,toolbar=Yes,menubar=Yes,location=no,scrollbars=yes,resizable=Yes');popwnd.focus()">
Export to Excel
</a>
</td>
</tr>
<tr>
<td colspan="2">
<table cellspacing="0" rules="all" border="1" id="dgPromisDataLog" style="border-color: Black; border-collapse: collapse;">
<tr class="rptDetailsHeaderMgt" align="center">
<td>LotID</td>
<td>Hist Stage</td>
<td>Datein</td>
<td>Dateout</td>
<td>Qtyin</td>
<td>Qtyout</td>
<td>M/C ID</td>
<td>Emp TrackOut</td>
<td>Hold Code</td>
<td>Hold Reason</td>
<td>Staging (Hrs)</td>
</tr>
<tr class="rptDetailsItemMgt" align="center" style="white-space: nowrap;">
<td>83508442.1</td>
<td>
<a
href="javascript:popwnd=window.open('LotGen_Dtl.aspx?iDate=04/09/2021 09:07:07 PM&amp;oDate=04/10/2021 03:47:59 PM&amp;oLotid=83508442.1&amp;oStage=C-WFRPROCS&amp;oLastRow=N','popwnd','width=900,height=600,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,top=100,right=50,left=50');popwnd.focus();"
>
C-WFRPROCS
</a>
</td>
<td>4/9/2021 9:07:07 PM</td>
<td>4/10/2021 3:47:59 PM</td>
<td>0</td>
<td>9</td>
<td></td>
<td>10911700</td>
<td> </td>
<td> </td>
<td>18.68</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
This is roughly my code
Sub Lotsearch()
Dim ie As InternetExplorer
Dim htmlEle As IHTMLElement
Dim i As Integer
Set ie = New InternetExplorer 'start new IE page
ie.Visible = True 'View what is happening in IE
ie.navigate "www.internalcompanywebsite.aspx" 'Open link in IE
While ie.readyState <> 4 'Waits for IE to finish loading
DoEvents
Wend
i = 1
'ie.document.getElementById("tblPromisDataLog") = Cells(2, 1).Value
'ie.document.getElementsByTagName("td").Value = Cells(5, 1).Value
'Set Data = ie.document.getElementByTagName("rptDetailsItemMgt")
'Dim myValue As String
'myValue = allRowOfData.Cells(0).innerHTML
'Cells(3, 13) = myValue
'Range("L1").Value = myValue
'For Each htmlEle In ie.document.getElementById("tblPromisDataLog")(0).getElementsByClassName("rptDetailsItemMgt")
With ActiveSheet
.Range("A" & i).Value = htmlEle.Children(0).textContent
' .Range("B" & i).Value = htmlEle.Children(1).textContent
' .Range("C" & i).Value = htmlEle.Children(2).textContent
' .Range("D" & i).Value = htmlEle.Children(3).textContent
' .Range("E" & i).Value = htmlEle.Children(4).textContent
' .Range("F" & i).Value = htmlEle.Children(5).textContent
' .Range("G" & i).Value = htmlEle.Children(6).textContent
' .Range("H" & i).Value = htmlEle.Children(7).textContent
' .Range("I" & i).Value = htmlEle.Children(8).textContent
' .Range("J" & i).Value = htmlEle.Children(9).textContent
' .Range("K" & i).Value = htmlEle.Children(10).textContent
' .Range("L" & i).Value = htmlEle.Children(11).textContent
End With
i = i + 1
Next htmlEle
ie.Quit
End Sub
As you can see, I have tried various methods but to no avail.
getElementbyID not working
getElementsbyTagName not working
getElementsByClassName not working
Any help would be appreciated. Thanks.

it may not actually be the most efficient way to deal with HTML extraction, but you might consider using Regex matching.. Raw Coding on youtube just made a killer regex tutorial, and I remembered seeing this question, and thought it might be a good alternative if you didn't like dealing with html explicitly.
Regex Tutorial for Beginners from Raw Coding on Youtube
like, if you only wanted normal text between td tags, you could regex search for
(?<OpenTag>[\<]+td[\>]+)(?<Contents>[\w\/\(\)\[\]\.\&\:\;\s]*?)(?<CloseTag>[\<]+[\/]+[td]+[\>]+)
here's an example at Regex101
Regex101 example using your html

Dim ht As HTMLDocument
Dim i As Integer
Dim htmltable As MSHTML.htmltable
Set htmltable = ht.getElementById("dgPromisDataLog")
myValue = htmltable.getElementsByClassName("rptDetailsItemMgt")(0).getElementsByTagName("td")(0).innerText
After messing with it for a few days, I found that the code works if I split up the getElementbyId from the other 'getElements'.
Changed htmlEle As IHTMLElement into ht As HTMLDocument. Also added htmltable As MSHTML.htmltable
For some reason the code returns an error if I chain the entire 'getelement' together. Hope this helps someone else with the same problem.

Related

How to get a tag in html with queryselectorall provided with a condition in VBA?

Snippet:
<table>
<tbody>
<tr>
<td valign="top" align="left">
<nobr>FILENAME</nobr>
</td>
<td valign="center" align="left">
<b>
<font size="2px">
<nobr>FILENUMBER0311</nobr>
</font>
</b>
<font size="2px"> </font>
</td>
<td valign="top" align="right"></td>
<tr>
<td valign="top" align="left">Date</td>
<td colspan="2" valign="center" align="left">
<font color="#C00000">
<b>
CANCELED
</b>
</tr>
…
<tr>
<td valign="top" align="left">
<nobr>FILENAME</nobr>
</td>
<td valign="center" align="left">
<b>
<font size="2px">
<nobr>FILENUMBER0345</nobr>
</font>
</b>
<font size="2px"> </font>
</td>
<td valign="top" align="right"></td>
<tr>
<td valign="top" align="left">Date</td>
<td colspan="2" valign="center" align="left">
<font color="#C00000">
<b>
CONFIRMED
</b>
</tr>
The website-html has a table with several tr-tags. In each tr-tag there is either the entry CONFIRMED between b-tags or the entry CANCELED. I need a code that returns the value of FILENUMBERxxxx in the case of CONFIRMED. I have no idea how to combine a "selector", "instr" and possible other operations with each other in this case.
My Code: (nothing happens!). Does anyone know a solution? THX
Sub GetData()
Const url = "https://www.zvg-portal.de/index.php?button=Suchen&all=1"
Dim Html As MSHTML.HTMLDocument
Dim xhr As Object, elm As Object
Dim I As Long
Set Html = New MSHTML.HTMLDocument
Set xhr = CreateObject("MSXML2.ServerXMLHTTP.6.0")
With xhr
.Open "POST", url, False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send "ger_name=--" & " " & "Alle" & " " & "Amtsgerichte" & " " & "--&" & "order_by=2&land_abk=ni&ger_id=0"
Html.body.innerHTML = .responseText
End With
With Html.querySelectorAll("tr")
Set elm = Html.querySelectorAll("tr")
For I = 0 To 500
'right now I do not know how to set the number of repeats, therefore 0 to 500
If InStr(elm.Item(I).innerText, "Termin") > 0 Then
ActiveSheet.Cells(I + 2, 3) = elm.Item(I).ParentNode.PreviousSibling.FirstChild.NextSibling.innerText
'need the numeric value of Aktenzeichen
Exit For
End If
Next I
End With
End Sub
The following processes the rows and when it sees a listing separator (tr with only 1 child td), it increments the row counter for the output array.
It uses an Instr test, for aufgehoben, to determine if the row with termin indicates a cancellation and returns a True/False value in the output array.
During the loop, the Aktenzeichen value is extracted; this is written out in the first column of the output array, before the True/False for cancelled.
Option Explicit
Public Sub GetData()
Const url = "https://www.zvg-portal.de/index.php?button=Suchen&all=1"
Dim html As MSHTML.HTMLDocument, xhr As Object
Set html = New MSHTML.HTMLDocument
Set xhr = CreateObject("MSXML2.XMLHTTP")
With xhr
.Open "POST", url, False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send "ger_name=--" & " " & "Alle" & " " & "Amtsgerichte" & " " & "--&" & "order_by=2&land_abk=ni&ger_id=0"
html.body.innerHTML = .responseText
End With
Dim table As MSHTML.HTMLTable
Set table = html.querySelector("table[border='0']")
Dim row As MSHTML.HTMLTableRow, newBlock As Boolean
Dim r As Long, cancellations(), aktenzeichen As String
ReDim cancellations(1 To 1000, 1 To 2)
r = 1
For Each row In table.Rows
If newBlock Then r = r + 1
If InStr(1, row.innerHTML, "Aktenzeichen", vbTextCompare) > 0 Then
aktenzeichen = Replace$(row.Children(1).getElementsByTagName("nobr")(0).innerText, " (Detailansicht)", vbNullString)
cancellations(r, 1) = aktenzeichen
End If
If Trim$(row.Children(0).innerText) = "Termin" Then
cancellations(r, 2) = (InStr(1, row.Children(1).innerText, "aufgehoben", vbTextCompare) > 0)
End If
newBlock = (row.Children.Length = 1)
Next
cancellations = Application.Transpose(cancellations)
Dim headers()
headers = Array(" Aktenzeichen", "Cancelled")
ReDim Preserve cancellations(1 To UBound(headers) + 1, 1 To r)
cancellations = Application.Transpose(cancellations)
With ActiveSheet
.Cells(1, 1).Resize(1, UBound(headers) + 1) = headers
.Cells(2, 1).Resize(UBound(cancellations, 1), UBound(cancellations, 2)) = cancellations
End With
End Sub

Replace text in file is not replacing string correctly

With below code I'm trying to add a anchor tag/hyperlink to a number in html file. Though I can see correct values in Local Window, same are not updated in file.
Don't know what's wrong.
Sub HyperlinkPRs() '''https://stackoverflow.com/questions/10434335/text-file-in-vba-open-find-replace-saveas-close-file
Dim rng As Range
Dim sBuf As String
Dim sTemp As String
Dim iFileNum As Integer
Dim sFileName As String
Dim var As String
lr = Worksheets("RawData").Cells(Rows.Count, 7).End(xlUp).Row
Set rng = Sheets("RawData").Range("G2:G" & lr)
' Edit as needed
sFileName = ThisWorkbook.Path & "\" & "data.html"
iFileNum = FreeFile
Open sFileName For Input As iFileNum
Do Until EOF(iFileNum)
Line Input #iFileNum, sBuf
sTemp = sTemp & sBuf & vbCrLf
Loop
Close iFileNum
''' Replace code
For i = 1 To lr
pr = Sheets("RawData").Range("G" & i).Value
link = "<a href=""" & _
"www.xyz.com/cgi-binr.pl?entry=" & _
pr & _
""">" & _
pr & _
"</a>" & "</td>"
sTemp = Replace(sTemp, pr & "</td>", link)
Next
iFileNum = FreeFile
Open sFileName For Output As iFileNum
Print #iFileNum, sTemp
Close iFileNum
End Sub
Values from local window (correct):
pr: 9525027
link = 9525027</td>
Replaced with:
9525027</td>
Input in text file:
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'>14</td>
<td class=xl6516703 style='border-top:none;border-left:none'>24</td>
<td class=xl7616703 style='border-top:none;border-left:none'>9525027</td>
Output:
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'>14</td>
<td class=xl6516703 style='border-top:none;border-left:none'>24</td>
<td class=xl7616703 style='border-top:none;border-left:none'>9525027</td>
Here is the (barely) modified routine you posted. Using your input data sample, I produced what I think is your desired output to a temporary file. Notice the check to determine if the old tag sub-string exists in the HTML. Also, my input data consisteed only of the three numeric tags. I did not modify the tags with </td>.
Sub HyperlinkPRs()
Dim rng As Range
Dim sBuf As String
Dim sTemp As String
Dim iFileNum As Integer
Dim sFileName As String
Dim var As String
lr = Worksheets("RawData").Cells(Rows.Count, 7).End(xlUp).Row
Set rng = Sheets("RawData").Range("G2:G" & lr)
' Edit as needed
'sFileName = ThisWorkbook.Path & "\" & "data.html"
sFileName = "C:\Temp\test1.html"
iFileNum = FreeFile
Open sFileName For Input As iFileNum
Do Until EOF(iFileNum)
Line Input #iFileNum, sBuf
sTemp = sTemp & sBuf & vbCrLf
Loop
Close iFileNum
Dim oldTag As String
Dim newLink As String
For i = 1 To lr
pr = Sheets("RawData").Range("G" & i).Value
oldTag = pr & "</td>"
If InStr(1, sTemp, oldTag) > 0 Then
newLink = "<a href=""" & _
"www.xyz.com/cgi-binr.pl?entry=" & _
pr & _
""">" & _
pr & _
"</a>" & "</td>"
sTemp = Replace(sTemp, oldTag, newLink)
Debug.Print "replaced " & oldTag
End If
Next
sFileName = "C:\Temp\test1out.html" 'temp file for debug
iFileNum = FreeFile
Open sFileName For Output As iFileNum
Print #iFileNum, sTemp
Close iFileNum
End Sub
Input data (C:\Temp\test1.html):
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'>14</td>
<td class=xl6516703 style='border-top:none;border-left:none'>24</td>
<td class=xl7616703 style='border-top:none;border-left:none'>9525027</td>
Output data (C:\Temp\test1out.html) produced by code:
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'> </td>
<td class=xl6516703 style='border-top:none;border-left:none'>14</td>
<td class=xl6516703 style='border-top:none;border-left:none'>24</td>
<td class=xl7616703 style='border-top:none;border-left:none'>9525027</td>

excel vba extract data from website table

I'm trying to scrape website and need only 1 value.
How do I retrieve purchase method using code below? see html below
Private Sub CommandButton1_Click()
Dim IE As Object
' Create InternetExplorer Object
Set IE = CreateObject("InternetExplorer.Application")
' You can uncoment Next line To see form results
IE.Visible = False
' URL to get data from
IE.Navigate Cells(1, 1)
' Statusbar
Application.StatusBar = "Loading, Please wait..."
' Wait while IE loading...
Do While IE.Busy
Application.Wait DateAdd("s", 5, Now)
Loop
Application.StatusBar = "Searching for value. Please wait..."
Dim tr As Object, td As Object, tb As Object
Dim value As String
Set tb = IE.Document.getElementById("prop_desc clearfix")
For Each tr In tb.Rows 'loop through the <tr> rows of your table
For Each td In tr.Cells 'loop through the <th> cells of your row
value = td.outerText 'your value is now in the variable "value"
MsgBox value
Next td
Next tr
' Show IE
IE.Visible = True
' Clean up
Set IE = Nothing
Application.StatusBar = ""
End Sub
</div>
</div>
<div class="prop_desc clearfix"><div class = "span-half">
<h3>RV Park/Campground for Sale</h3>
<table>
<tr>
<td>Number of RV Lots: </td>
<td>270</td>
</tr>
<tr>
<td>Size:</td>
<td>
157 acre(s)
</td>
</tr>
<tr>
<td>Purchase Method:</td>
<td>Cash, New Loan</td>
</tr>
<tr>
<td>Status:</td>
<td>
Active
</td>
</tr>
<tr>
<td>Property ID:</td>
<td>966994</td>
</tr>
<tr>
<td>Posted on:</td>
<td>Jul 10, 2018</td>
</tr>
<tr>
<td>Updated on:</td>
<td>Jul 10, 2018</td>
</tr>
<tr>
You can target by class by index and then the td by index
Option Explicit
Public Sub GetInfo()
Dim IE As New InternetExplorer
With IE
.Visible = True
.navigate "https://www.rvparkstore.com/rv-parks/902077--2843-lake-frontage-42-acres-for-sale-in-north-central-us"
While .Busy Or .readyState < 4: DoEvents: Wend
Debug.Print .document.getElementsByClassName("span-half")(0).getElementsByTagName("td")(5).innerText
.Quit '<== Remember to quit application
End With
End Sub
UPDATE:
Url https://www.rvparkstore.com/rv-parks/902077--2843-lake-frontage-42-acres-for-sale-in-north-central-us
HTML Here https://docs.google.com/document/d/1J5tDV99IbzucCB_z8QX8lDa4X3ecxQbQOWeVy5B7Irg/edit?usp=sharing
please use links for more info jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj

how to find location of specific <tr> each time code is run

My code below will extract a value for each hour of the day.
However, the webpage I'm scraping can change and so I want to find a way to assign the location of the to a variable so that it will know what number it is everytime. I found the current number "116" by trial and error.
I included the html structure below as well. Any suggestions?
Sub scrape()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.application")
With IE
.Visible = False
.navigate "web address"
Do Until .readyState = 4
DoEvents
Loop
.document.all.item("Login1_UserName").Value = "user"
.document.all.item("Login1_Password").Value = "pw"
.document.all.item("Login1_LoginButton").Click
Do Until .readyState = 4
DoEvents
Loop
End With
Dim htmldoc As Object
Dim r
Dim c
Dim aTable As Object
Dim TDelement As Object
Set htmldoc = IE.document
Dim td As Object
For Each td In htmldoc.getElementsByTagName("td")
On Error Resume Next
If span.Children(0).id = "ctl00_PageContent_grdReport_ctl08_Label50" Then
ThisWorkbook.Sheets("sheet1").Range("j8").Offset(r, c).Value = td.Children(1).innerText
End If
On Error GoTo 0
Next td
End Sub
HTML:
<form name="aspnetForm" id="aspnetForm" action="./MinMaxReport.aspx"
method="post">
<div>
</div>
<script type="text/javascript">...</script>
<div>
</div>
<table class="header-table">...</table>
<table class="page-area">
<tbody>
<tr>
<table id="ctl00_PageContent_Table1" border="0">...</table>
<table id="ctl00_PageContent_Table2" border="0">
<tbody>
<tr>
<td>
<div id="ctl00_PageContent_grdReport_div">
<tbody>
<tr style="background-color: beige;">
<td>...</td>
<td>
<span id="ctl00_PageContent_grdReport_ctl08_Label50">Most Restrictive
Capacity Maximum</span>
</td>
<td>
<span id="ctl00_PageContent_grdReport_ctl08_Label51">159</span>
</td>
</tr>
</tbody>
</div>
</td>
</tr>
</tbody>
</table>
</table>
</tr>
</tbody>
</table>
You could loop through all TDs and check if id= "ctl00_PageContent_grdReport_ctl08_Label50" for example:
For Each td In htmldoc.getElementsByTagName("td")
On Error Resume Next
If td.Children(0).ID = "ctl00_PageContent_grdReport_ctl08_Label50" Then
ThisWorkbook.Sheets("sheet1").Range("j8").Offset(r, c).Value = td.Children(1).innerText
End If
On Error GoTo 0
Next td
Children(0) will pick the first iHTML element contained in your table cell. On Error Resume Next is for the situation when td element has no child.
It is possible that you have more then one element with this id in your webpage. Then, you must identify table or table row first. I cannot do it because I can't see your whole HTML code.

How to use getElementsByTagName with <td> with overflow: hidden on VBA?

I am using the VBA automation to get some informations of a ticket system in my job. I am trying to get the value into the generated table but only information that doest'go to the column "A" on sheet "Plan1" is <td> which contains the overflow: hidden CSS atribute. I don't know if are them related but coincidently are the only data that don't appears. Someone can help me?
HTML code:
<div id="posicionamentoContent">
<table class="grid">
<thead>...</thead>
<tbody>
<tr id="937712" class="gridrow">
<td width="200px"> Leonardo Peixoto </td>
<td width="200px"> 23/12/2015 09:45 </td>
<td width="200px"> SIM </td>
<td width="200px"> Telhado da loja com pontos de vazamento.</td>
<td width="200px" align="center"></td>
<td width="200px" align="center"></td>
</tr>
...
...
...
The complete code: http://i.stack.imgur.com/4BsFo.png
I need to get the first 4 <td> text ( Leonardo Peixoto, 23/12/2015 09:45, SIM and Telhado da loja com pontos de vazamento.) but they are only texts which I can't get.
Obs: When I use developers tools (f12) to inspect each element, it shows me perfectly the information I need inside <td>. But when I open "source code" page to checkthe html, the code is like this:
<div id="tabPosicionamento" style="padding: 5px 0 5px 0;" class="ui-tabs-hide">
div id="posicionamentoContent"></div>
</div>
Example VBA:
Sub extractTablesData1()
'we define the essential variables
Dim IE As Object, obj As Object
Dim ticket As String
Set IE = CreateObject("InternetExplorer.Application")
ticket= InputBox("Enter the ticket code")
With IE
.Visible = False
.navigate ("https://www.example.com/details/") & ticket
While IE.ReadyState <> 4
DoEvents
Wend
ThisWorkbook.Sheets("Plan1").Range("A1:K500").ClearContents
Set data = IE.document.getElementsByClassName("thead")(0).getElementsByTagName("td")
i = 0
For Each elemCollection In data
ThisWorkbook.Sheets("Plan1").Range("A" & i + 1) = data(i).innerText
i = i + 1
Next elemCollection
End With
IE.Quit
Set IE = Nothing
....
....
End Sub
This function returns in column "A" of sheet Plan1 only <td class=info3"></td> and <td class=info4"></td> but I need <td class=info1"></td> and <td class=info2 also."></td>
I wasn't able to read the page code due the proxy blocking me, but I faced a similar issue a while ago and the solution I found out was put all data on clipboard and paste. After that I clean the data on the sheet.
Here the code I used to do that:
Set ieTable = ie.document.getElementById("ID")
If Not ieTable Is Nothing Then
Set clip = New DataObject
clip.SetText "<html>" & ieTable.outerHTML & "</html>"
clip.PutInClipboard
Sheet1.Range("A1").Select
ActiveSheet.PasteSpecial Format:="Unicode Text", link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
End If
Considering that you need to isolate the 4 td lines, you can do that with a loop for every search.
In your sample it numerates the Data, but not using it. Also, the cell assignment should be cells(x,y).value. Here is the working code.
Sub extractTablesData1()
'we define the essential variables
Dim IE As Object, Data As Object
Dim ticket As String
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = False
.navigate ("put your data url here")
While IE.ReadyState <> 4
DoEvents
Wend
Set Data = IE.document.getElementsByTagName("tr")(0).getElementsByTagName("td")
i = 1
For Each elemCollection In Data
ActiveWorkbook.Sheets(1).Cells(1, i).Value = elemCollection.innerHTML
i = i + 1
Next elemCollection
End With
IE.Quit
Set IE = Nothing
End Sub
It doesn't bring the information what I need (lasts <td>)
<div id="posicionamentoContent">
<table class="grid">
<thead>...</thead>
<tbody>
<tr id="937712" class="gridrow">
<td width="200px"> Leonardo Peixoto </td>
<td width="200px"> 23/12/2015 09:45 </td>
<td width="200px"> SIM </td>
<td width="200px"> Telhado da loja com pontos de vazamento.</td>
<td width="200px" align="center"></td>
<td width="200px" align="center"></td>
</tr>