- 帖子
- 25
- 主題
- 4
- 精華
- 0
- 積分
- 50
- 點名
- 0
- 作業系統
- xp
- 軟體版本
- office 2003
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2012-3-31
- 最後登錄
- 2014-6-8
|
[發問] [請教]個股成交資訊以VBA擷取之問題...
各位大大請教一下:
我想從證交所的個股日成交資訊擷取資料,
希望是能夠由EXCEL表格內輸入"股票代碼"&"年"&"月",來更新data,
以下巨集是參考別人的寫法進行修改,
但是一直沒辦法將資料抓進來,
請問各位大大是巨集有哪裡寫錯了嗎?
還是可以有更好的寫法???
謝謝!!- Sub 個股日成交資訊()
- '
- Dim ptxt As String
- Dim STK_NO, myear, mmon
- myear = InputBox("輸入查詢民國年", "個股日成交資訊")
- If myear = "" Then Exit Sub
- mmon = InputBox("輸入查詢月", "個股日成交資訊")
- If mmon = "" Then Exit Sub
- STK_NO = InputBox("輸入個股代碼", "個股日成交資訊")
- If STK_NO = "" Then Exit Sub
- With ActiveSheet.QueryTables.Add(Connection:= _
- "URL;http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/STOCK_DAYMAIN.php" _
- , Destination:=Range("A1"))
- .PostText = "ajax=true&myear=" & myear & "&mmon=" & mmon & "&STK_NO=" & STK_NO
- .PreserveFormatting = False
- .RowNumbers = False
- .FillAdjacentFormulas = False
- .RefreshOnFileOpen = False
- .BackgroundQuery = True
- .RefreshStyle = xlInsertDeleteCells
- .SavePassword = False
- .SaveData = True
- .AdjustColumnWidth = True
- .RefreshPeriod = 0
- .WebSelectionType = xlSpecifiedTables
- .WebFormatting = xlWebFormattingNone
- .WebTables = "8"
- .WebPreFormattedTextToColumns = True
- .WebConsecutiveDelimitersAsOne = True
- .WebSingleBlockTextImport = False
- .WebDisableDateRecognition = False
- .WebDisableRedirections = False
- .Refresh BackgroundQuery:=False
-
- End With
- End Sub
複製代碼 |
|