- 帖子
- 48
- 主題
- 6
- 精華
- 0
- 積分
- 60
- 點名
- 0
- 作業系統
- XP
- 軟體版本
- Office 2003
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2012-8-13
- 最後登錄
- 2023-2-7
|
我也來測試一下,的確可以work!
但是
.WebSelectionType = xlEntirePage
會抓太多不必要的資料
---------------------
Sub WEBQ()
' 興櫃個股歷史行情
Dim ptxt As String
Dim yy, stock
Sheet1.Activate
If Sheet1.QueryTables.Count = 0 Then
Sheet1.QueryTables.Add Connection:="URL;", Destination:=Range("A1:E1")
End If
'yy = InputBox("輸入查詢月份", "國年/月份")
yy = "103/02"
If yy = "" Then Exit Sub
'stock = InputBox("輸入股票代碼", "個股")
'4990 晶美
stock = "4990"
If stock = "" Then Exit Sub
With Sheet1.QueryTables(1)
.Connection = "URL;http://www.gretai.org.tw/ch/emergingstock/single_historical/history.php"
.PreserveFormatting = False
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebDisableDateRecognition = True
.PostText = "ajax=true&input_month=" & yy & "&input_emgstk_code=" & stock
.Refresh BackgroundQuery:=False
End With
'
End Sub |
|