我一直在試圖爲下表導入Excel表導入到Excel,是由一個腳本從網頁
www.bursamalaysia.com/market/securities/equities/indices/
產生我試過了PowerQuery,數據選項卡「From Web」等。從我的研究中,我認爲Excel無法「看見」數據的原因是因爲它是用Javascript動態生成的。
我希望任何幫助,試圖通過PowerQuery甚至VBA腳本獲取表格到Excel中。
我看到類似的東西at this並修改它如下,但我得到一個空表。
Sub Bursa_Indices()
Dim xmlHttp As Object
Dim TR_col As Object, TR As Object
Dim TD_col As Object, TD As Object
Dim row As Long, col As Long
Set xmlHttp = CreateObject("MSXML2.XMLHTTP.6.0")
xmlHttp.Open "GET", "http://www.bursamalaysia.com/market/securities/equities/indices/", False
xmlHttp.setRequestHeader "Content-Type", "text/xml"
xmlHttp.send
Dim html As Object
Set html = CreateObject("htmlfile")
html.body.innerHTML = xmlHttp.ResponseText
Dim tbl As Object
Set tbl = html.getElementById("bm_indices_prices_table")
row = 1
col = 1
Set TR_col = html.getelementsbytagname("TR")
For Each TR In TR_col
Set TD_col = TR.getelementsbytagname("TD")
For Each TD In TD_col
Cells(row, col) = TD.innerText
col = col + 1
Next
col = 1
row = row + 1
Next
結束子
預先感謝。
請發佈您正在運行的VBA腳本和您收到的錯誤。 – thodic
來自VBA腳本的錯誤是 的錯誤http://stackoverflow.com/questions/21039677/import-data-in-excel-from-a-table-created-by-a-script-in-a - 網頁 我想我已經找出了錯誤。網址已從http更改爲https。我試圖修改它到我的網址,但只是變得空白到目前爲止。 – Jason