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("輸入查詢月份", "國年/月份")
If yy = "" Then Exit Sub
stock = InputBox("輸入股票代碼", "個股")
If stock = "" Then Exit Sub
With Sheet1.QueryTables(1)
.Connection = "URL;http://www.otc.org.tw/ch/emergingstock/single_historical/result.php"
.PreserveFormatting = False
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebDisableDateRecognition = True
.PostText = "ajax=true&input_month=" & yy & "&stk_code=" & stock
.Refresh False
End With
End Sub作者: pbchen 時間: 2014-2-24 17:42
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作者: heavenweaver 時間: 2014-2-26 08:42