0
我正在開發一個宏,用於從Internet Explorer表中獲取數據並在Excel表格中加載。從Internet Explorer獲取數據至excel
有了這個代碼,我可以得到表的冠軍,但我不能讓內容
Sub extraerDatos()
Dim URL As String
Dim IE As InternetExplorer
Dim HTMLdoc As HTMLDocument
Dim TDelements As IHTMLElementCollection
Dim TDelement As HTMLTableCell
Dim oElement As Object
Dim r As Long
URL = "URL"
Set IE = New InternetExplorer
With IE
.Navigate URL
.Visible = True
'Cargar pagina
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
Set HTMLdoc = .Document
End With
Application.Wait (Now + TimeValue("0:00:10"))
Set dados = HTMLdoc.getElementsByClassName("tableContainer")
(0).getElementsByTagName("span")
I = 0
For Each oElement In dados
Sheets("Hoja1").Range("A" & I + 1) = dados(I).innerText
I = I + 1
Next oElement
End Sub
這是
<div class="tableContainer" >
<div class="tlnTable tlnw12" id="tlnAngTableTransfers" style="display:none" >
<span style="margin:0; padding-bottom: 10px;" class="field-validation-error ng-binding" ng-show="model.bTransferRequired">Select at least one transfer</span>
<div class="tlnHeader tlnw12"> <!-- HEADER -->
<div class="tlnw3">
<div class="tlnw1 tlntd">
<input type="checkbox" ng-model="model.grid.selected" ng-change="model.grid.selectAll()"/>
</div>
<div class="tlnw6 tlntd">
<a href="#" class="tlnSortLink tlnw12" ng-click="model.grid.sortableColumns.columns.transferId.changeSort()">
<span class="tlnw10">Transfer ID/PO-SO Number </span>
<span class="tlnSortIco tlnw2" ng-show="model.grid.sortableColumns.lastSortedColumn.id === model.grid.sortableColumns.columns.transferId.id" >
<span class="tlnSortAsc tlnw12 " ng-class="{act: model.grid.sortableColumns.lastSortedColumn.modifier==='asc', inact: model.grid.sortableColumns.lastSortedColumn.modifier==='desc'}" ></span>
<span class="tlnSortDesc inact tlnw12" ng-class="{act: model.grid.sortableColumns.lastSortedColumn.modifier==='desc', inact: model.grid.sortableColumns.lastSortedColumn.modifier==='asc'}"></span>
</span>
</a>
</div>
據我所知,在頁面的HTML代碼的一部分在NG標記是表的內容,但我不知道如何得到它,我的電子表格..
感謝您的幫助
嗨Ryguy..Thanks非常有趣,因爲有了這個宏,我得到頁面的所有數據。但是可以選擇特定的標籤或ID來定界列D的信息嗎? – hdan7
我不確定你的意思。你能發表一個例子嗎?另外,要知道你可以用IF ... THEN語句測試itm.innertext的內容。 – ryguy72