Set XML = CreateObject("Microsoft.XMLHTTP")
Set Stream = CreateObject("ADODB.stream")
Dim path As String, thePOSTdata, URL
Dim stockID()
col = 0
row = 1
topic = 0
stockID = Array(2605, 2606, 2607, 2608)
URL = "http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/STOCK_DAYMAIN.php"
For x = 0 To UBound(stockID)
For y = 2014 To 2016
For z = 1 To 12
If xlYear = 2016 And xlMonth = 11 Then '超過目前日期則跳出迴圈
Exit For
End If
thePOSTdata = "download=csv&query_year=" & y & "&query_month=" & z & "&CO_ID=" & stockID(x)
XML.Open "POST", URL, 0
XML.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
XML.send thePOSTdata