- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
8#
發表於 2013-11-27 10:46
| 只看該作者
回復 7# pupai
按下 圖片的網址 http://mops.twse.com.tw/server-j ... N=3&REPORT_ID=C- Option Explicit
- Sub Ex()
- Dim URL As String, xCo_Id As String, xSyear As String, xSseason As String
- xCo_Id = "[" & """股票代號""" & "," & """2485""" & "]" '要求輸入網頁的參數:股票代號
- xSyear = "[" & """年度""" & "," & """" & Format(Date, "e") & """" & "]" 'Format(Date, "e")->中華民國的年度
- xSseason = "[" & """季別""" & "," & """" & Format(Date, "q") & """" & "]" 'Format(Date, "q")->當年度的季別
- URL = "URL;http://mops.twse.com.tw/server-java/t164sb01?step=1&CO_ID=" & xCo_Id & "&SYEAR=" & xSyear & "&SSEASON=" & xSseason & "&REPORT_ID=C"
- With ActiveSheet.QueryTables.Add(Connection:=URL, Destination:=Range("A1"))
- .AdjustColumnWidth = False '自動調整欄寬
- .WebSelectionType = xlSpecifiedTables
- .WebFormatting = xlWebFormattingNone
- .WebTables = "2,3,4" '資產負債表,綜合損益表,現金流量表
- .WebPreFormattedTextToColumns = True
- .WebConsecutiveDelimitersAsOne = True
- .WebSingleBlockTextImport = False
- .WebDisableDateRecognition = False
- .WebDisableRedirections = False
- .Refresh BackgroundQuery:=False
- End With
- End Sub
複製代碼 |
|