- 帖子
- 79
- 主題
- 2
- 精華
- 0
- 積分
- 193
- 點名
- 0
- 作業系統
- Winwos 7 64 bits
- 軟體版本
- Excel 2003/2007
- 閱讀權限
- 20
- 性別
- 男
- 來自
- TAIPEI
- 註冊時間
- 2010-8-25
- 最後登錄
- 2019-9-20
|
回復 1# spermbank - Sub 抓財報(財報別, 市場別, 年, 季)
-
- Select Case 財報別
- Case "損益": 程式 = "ajax_t51sb08"
- Case "資產": 程式 = "ajax_t51sb07"
- Case "合併損益": 程式 = "ajax_t51sb13"
- Case "合併資產": 程式 = "ajax_t51sb12"
- End Select
-
- Select Case 市場別
- Case "上市": 市場 = "sii"
- Case "上櫃": 市場 = "otc"
- Case "興櫃": 市場 = "rotc"
- Case "公開": 市場 = "pub"
- End Select
-
- '原始網址 http://mops.twse.com.tw/mops/web/ajax_t51sb07?encodeURIComponent=1&step=1&firstin=1&off=1&TYPEK=sii&year=101&season=04
- theURL = "http://mops.twse.com.tw/mops/web/" & 程式 & "?encodeURIComponent=1&step=1&firstin=1&off=1&TYPEK=" & 市場 & "&year=" & 年 & "&season=" & 季
-
- With ActiveSheet.QueryTables.Add(Connection:="URL;" & theURL, Destination:=Range("A1"))
- .Name = "抓財報"
- .BackgroundQuery = True
- .RefreshStyle = xlOverwriteCells
- .RefreshPeriod = 0
- .WebSelectionType = xlEntirePage
- .WebFormatting = xlWebFormattingNone
- .WebDisableDateRecognition = False
- .WebDisableRedirections = False
- .Refresh BackgroundQuery:=False
- .Delete
- End With
-
- End Sub
複製代碼 1. 以上程式碼僅抓資料,並未處理金融保險證券...類股會計科目不同的問題
2. 使用範例 call 抓財報( "損益","上櫃",101,"04") |
|