標題:
抓WEB資料出現「應用程式或物件定義上的錯誤」
[打印本頁]
作者:
tsunamix03
時間:
2016-10-14 20:41
標題:
抓WEB資料出現「應用程式或物件定義上的錯誤」
Dim xlMonth As String, row As Integer
row = 2 '放置資料的起始列 須更改
For yr = 92 To 92 '取得的年份歷史資料 視需要更改
For m = 8 To 12 '取得的月份歷史資料 視需要更改
xlMonth = Format(m, "00")
Sheets(42).Activate
With ActiveSheet.QueryTables.Add(Connection:="URL;http://siis.twse.com.tw/publish/sii/" & yr & "IRB130_" & xlMonth & ".HTM", Destination:=Sheets(42).Range("o1"))
'.Name = stockID & "_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "2"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
'With ActiveSheet.QueryTables.Add(Connection:= _
' "URL;http://siis.twse.com.tw/publish/sii/" & yr & "IRB130_" & xlMonth & ".HTM", Destination:=Range _
' ("O1"))
' .Name = "92IRB130_08"
' .FieldNames = True
' .RowNumbers = False
' .FillAdjacentFormulas = False
' .PreserveFormatting = True
' .RefreshOnFileOpen = False
' .BackgroundQuery = True
' .RefreshStyle = xlInsertDeleteCells
' .SavePassword = False
' .SaveData = True
' .AdjustColumnWidth = True
' .RefreshPeriod = 0
' .WebSelectionType = xlSpecifiedTables
' .WebFormatting = xlWebFormattingNone
' .WebTables = "2"
' .WebPreFormattedTextToColumns = True
' .WebConsecutiveDelimitersAsOne = True
' .WebSingleBlockTextImport = False
' .WebDisableDateRecognition = False
' .WebDisableRedirections = False
' .Refresh BackgroundQuery:=False
'End With
Cells(row, "B") = Cells(1500, "P")
Cells(row, "C") = Cells(1500, "S")
Cells(row, "D") = Cells(1500, "U")
Cells(row, "E") = Cells(1500, "V")
Cells(row, "F") = Cells(1500, "W")
row = row + 1
Next
Next
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)