- 帖子
- 184
- 主題
- 45
- 精華
- 0
- 積分
- 407
- 點名
- 0
- 作業系統
- WIN 7
- 軟體版本
- office 2010
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2010-8-19
- 最後登錄
- 2025-6-3

|
您好
我希望程式可以依照我想要的日期下載當天資料
可以幫我指導修改
謝謝!!- Option Explicit
- Sub EX()
-
-
- Dim URL As String, xCo_Id As String, xSyear As String, xSseason As String
-
- xCo_Id = Range("B1").Value
- xSyear = Range("B2").Value
- xSseason = Range("B3").Value
-
- 'xCo_Id = "[" & """年度""" & "," & """102年""" & "]"
- '要求輸入網頁的參數:年度
- 'xSyear = "[" & """月份""" & "," & """月 """ & "]"
- 'Format(Date, "e")->中華民國的月份
- 'xSseason = "[" & """日""" & "," & """日期""" & "]"
- 'Format(Date, "q")->當年度的日期
-
- '外資及陸資買賣超彙總表
- URL = "URL;http://www.twse.com.tw/ch/trading/fund/TWT38U/TWT38U.php?step=1&CO_ID=" & xCo_Id & "&SYEAR=" & xSyear & "&SSEASON=" & xSseason & "&REPORT_ID=C"
- With ActiveSheet.QueryTables.Add(Connection:=URL, Destination:=Range("D4"))
- .AdjustColumnWidth = False '自動調整欄寬
- .WebSelectionType = xlSpecifiedTables
- .WebFormatting = xlWebFormattingNone
- .WebTables = "2"
- .WebPreFormattedTextToColumns = True
- .WebConsecutiveDelimitersAsOne = True
- .WebSingleBlockTextImport = False
- .WebDisableDateRecognition = False
- .WebDisableRedirections = False
- .Refresh BackgroundQuery:=False
- End With
- '投信買賣超彙總表
- URL = "URL;http://www.twse.com.tw/ch/trading/fund/TWT44U/TWT44U.php?step=1&CO_ID=" & xCo_Id & "&SYEAR=" & xSyear & "&SSEASON=" & xSseason & "&REPORT_ID=C"
- With ActiveSheet.QueryTables.Add(Connection:=URL, Destination:=Range("K5"))
-
- .AdjustColumnWidth = False '自動調整欄寬
- .WebSelectionType = xlSpecifiedTables
- .WebFormatting = xlWebFormattingNone
- .WebTables = "2"
- .WebPreFormattedTextToColumns = True
- .WebConsecutiveDelimitersAsOne = True
- .WebSingleBlockTextImport = False
- .WebDisableDateRecognition = False
- .WebDisableRedirections = False
- .Refresh BackgroundQuery:=False
-
- End With
-
- End Sub
複製代碼 |
|