• 2

請教各位,EXECL問題

請教各位高手,我要如何使用ececl導入上市所有當日股票資料.

http://www.twse.com.tw/ch/trading/exchange/MI_INDEX/genpage/Report201212/A11220121210ALLBUT0999_1.php?select2=ALLBUT0999&chk_date=101/12/10#

但是要每天都要會自動更新 (目前被"日期"給限制住了)

目前使用ececl/資料/匯入外部資料/新增web查詢,,,,,,但,他不會自動更新日期.

還是有其它方式,可以用ececl/資料/匯入外部資料/新增web查詢.查詢的網頁.

小弟只會這個功能...........
2012-12-10 22:31 發佈
文章關鍵字 execl 問題
歡迎到 http://www.taconet.com.tw/oskwu 與 http://tw.myblog.yahoo.com/warrant_oskwu
oskwu wrote:
小弟這裡有匯入資料的...(恕刪)


樓主的問題是網址裡有日期在裡面
http://www.twse.com.tw/ch/trading/exchange/MI_INDEX/genpage/Report201212/A11220121210ALLBUT0999_1.php?select2=ALLBUT0999&chk_date=101/12/10#
所以每天的網址都要更改
這要用vba寫比較快
把以下貼到excel 的 marco 裡
執行macro就會匯入當天的資料

Sub I_am_fat()

Dim dumb1 As String
Dim dumb2 As String
Dim dumb3 As String

dumb1 = Val(Left(Date, 4)) - 1911 & "-" & Mid(Date, 6, 2) & "-" & Right(Date, 2)
dumb2 = Left(Date, 4) & Mid(Date, 6, 2) & Right(Date, 2)
dumb3 = Left(Date, 4) & Mid(Date, 6, 2)

With ActiveSheet.QueryTables.Add(Connection:= _
"url;http://www.twse.com.tw/ch/trading/exchange/MI_INDEX/genpage/Report" & dumb3 & "/A112" & dumb2 & "ALLBUT0999_1.php?select2=ALLBUT0999&chk_date=" & dumb1 & "101/12/10#" _
, Destination:=Range("$A$1"))
.Name = _
"search?q=%3Cfont+color%3D%22%23FF0000%22%3E101%2F12%2F10%3C%2Ffont%3E&src=ie9tr"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub


petrojelly wrote:
select2=ALLBUT0999&chk_date=" & dumb1 & "101/12/10#" _


101/12/10# 沒有設變數?

謝謝大大的回覆,目前執行有錯誤,在煩請大大,抽空幫忙更新.

謝謝
修正錯誤.
現在執行會找不到網址, 因為今天的收盤資料還未產生

Sub I_am_fat()

Dim dumb1 As String
Dim dumb2 As String
Dim dumb3 As String

dumb1 = Val(Left(Date, 4)) - 1911 & "-" & Mid(Date, 6, 2) & "-" & Right(Date, 2)
dumb2 = Left(Date, 4) & Mid(Date, 6, 2) & Right(Date, 2)
dumb3 = Left(Date, 4) & Mid(Date, 6, 2)

With ActiveSheet.QueryTables.Add(Connection:= _
"url;http://www.twse.com.tw/ch/trading/exchange/MI_INDEX/genpage/Report" & dumb3 & "/A112" & dumb2 & "ALLBUT0999_1.php?select2=ALLBUT0999&chk_date=" & dumb1 & "#" _
, Destination:=Range("$A$1"))
.Name = _
"search?q=%3Cfont+color%3D%22%23FF0000%22%3E101%2F12%2F10%3C%2Ffont%3E&src=ie9tr"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub

謝謝,大大的立即回覆,小弟晚上回去,在試用一下,若有問題,在打擾大大了.

先謝謝大大的教學與分享.
如果要抓單隻股票的歷史資料, 有沒有好的網頁可以用?


天使晚安 wrote:
如果要抓單隻股票的歷...(恕刪)





http://money.hinet.net/z/z0/z00/z00a.djhtm

151515151515
  • 2
內文搜尋
X
評分
評分
複製連結
Mobile01提醒您
您目前瀏覽的是行動版網頁
是否切換到電腦版網頁呢?