- 帖子
- 40
- 主題
- 10
- 精華
- 0
- 積分
- 83
- 點名
- 0
- 作業系統
- winxp
- 軟體版本
- office2003
- 閱讀權限
- 20
- 註冊時間
- 2011-6-3
- 最後登錄
- 2020-10-1
|
26#
發表於 2014-12-16 19:46
| 只看該作者
Sheets("上櫃股票").Activate
With CreateObject("InternetExplorer.application") '創建一個空的ie
.Visible = True '讓ie可見
.Navigate "http://www.gretai.org.tw/web/stock/aftertrading/broker_trading/brokerBS.php?l=zh-tw"
Do Until .ReadyState = 4 '等待ie完畢載入
DoEvents
Loop
code = InputBox("輸入查詢code", "code", code)
For Each stock In Range([a2], [a65536].End(xlUp))
.document.All("stk_code").Value = stock
.document.All("auth_num").Value = code 'Cells(1, 1)
With Sheets("web")
.Cells.Delete
.QueryTables.Add Connection:="URL;", Destination:=.Range("A1")
DoEvents
With .QueryTables.Add(Connection:="URL;http://www.gretai.org.tw/web/stock/aftertrading/broker_trading/download_ALLCSV.php?curstk=" & stock & "&stk_date=" & 日期 & "&auth=" & code & "", Destination:=.[a1])
.AdjustColumnWidth = False
.WebFormatting = xlWebFormattingNone
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=False
End With
.Columns("A:A").TextToColumns Destination:=.Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1)), _
TrailingMinusNumbers:=True
If .[a4] = " " Then .Cells.Delete: GoTo a
End With
If Sheets("web").[a4] = "驗證碼已逾期,請重新查詢" Then
stock.Offset(, 2) = "ng"
.Quit
.Visible = True '讓ie可見
.Navigate "http://www.gretai.org.tw/web/stock/aftertrading/broker_trading/brokerBS.php?l=zh-tw"
Do Until .ReadyState = 4 '等待ie完畢載入
DoEvents
Loop
code = InputBox("輸入查詢code", "code", code)
GoTo a
End If
整頁下載 '資訊整理
a:
Next
End With
程序很亂相互參考一下! |
|