Sub EX()
Dim A As Date
Dim Rep_Ym As String
Dim Rep_Day As String
Range("A1") = "2011/12/20" '示範的日期
A = Range("A1").Value
Rep_Ym = Format(A, "yyyyMM")
Rep_Day = Format(A, "yyyyMMDD")
With ActiveSheet
If .QueryTables.Count = 0 Then
With .QueryTables.Add("URL;about:Tabs", .[B1])
.Refresh BackgroundQuery:=False
End With
End If
With .QueryTables(1)
'全部下載久一點
.Connection = "URL;http://www.twse.com.tw/ch/trading/exchange/MI_MARGN/genpage/Report" & Rep_Ym & "/A112" & Rep_Day & "_1.php"
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "10"
'這全部的要用 .WebTables = "10"
'其他項目的要用 .WebTables = "8"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
Dim A As Date
Dim Rep_Ym As String
Dim Rep_Day As String
Dim param As String
A = Range("A1").Value
Rep_Ym = Format(A, "yyyyMM")
Rep_Day = Format(A, "yyyyMMDD")
param = (y - 1911) & "/" & m & "/" & d ' 民國年/月/日
Workbooks.Open Filename:= _
"http://www.tpex.org.tw/web/stock/margin_trading/margin_balance/margin_bal_download.php?l=zh-tw" & Rep_Ym & "s=0,asc,1"
End Sub
Sub EX()
Dim A As Date
Dim Rep_Ym As String
Dim Rep_Day As String
Range("A1") = "2011/12/20" '示範的日期
A = Range("A1").Value
Rep_Ym = Format(A, "yyyyMM")
Rep_Day = Format(A, "yyyyMMDD")
With ActiveSheet
If .QueryTables.Count = 0 Then
With .QueryTables.Add("URL;about:Tabs", .[B1])
.Refresh BackgroundQuery:=False
End With
End If
With .QueryTables(1)
'全部下載久一點
.Connection = "URL;http://www.twse.com.tw/ch/trading/exchange/MI_MARGN/genpage/Report" & Rep_Ym & "/A112" & Rep_Day & "_1.php"
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "10"
'這全部的要用 .WebTables = "10"
'其他項目的要用 .WebTables = "8"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False