- ©«¤l
- 361
- ¥DÃD
- 57
- ºëµØ
- 0
- ¿n¤À
- 426
- ÂI¦W
- 0
- §@·~¨t²Î
- win7
- ³nÅ骩¥»
- 2003,2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-5-13
- ³Ì«áµn¿ý
- 2022-12-8
|
¦^´_ 3# clianghot546
¤U¸ücsv ¡A¶×¤J¦A§R°£§Y¥i- Sub ӪѤ馬½L»ù¤Î¤ë¥§¡»ùCSV()
- Dim xml As Object
- Dim stream
- Dim URL As String
- ¦~ = 2016
- ¤ë = 2
- ªÑ²¼¥N½X = 2498
- Set xml = CreateObject("Microsoft.XMLHTTP") '¥Î¨Ó¨ú±oºô¶¸ê®Æ
- Set stream = CreateObject("ADODB.stream") 'ADODB.stream '¥Î¨ÓÀx¦s¤G¶i¦ìÀÉ®×
- URL = "http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY_AVG/STOCK_DAY_AVGMAIN.php"
- xml.Open "POST", URL, 0
- xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- xml.send "download=csv&query_year=" & ¦~ & "&query_month=" & ¤ë & "&CO_ID=" & ªÑ²¼¥N½X
- With stream
- .Open
- .Type = 1
- .write xml.ResponseBody
- 'SaveToFile:ÀɮצWºÙ¤w¦s¦b®É·|¦³¿ù»~,¶·¥ý§R°£¤w¦s¦bªºÀɮצWºÙ
- If Dir(ThisWorkbook.Path & "\" & ªÑ²¼¥N½X & ".CSV") <> "" Then Kill ThisWorkbook.Path & "\" & ªÑ²¼¥N½X & ".CSV"
- .SaveToFile (ThisWorkbook.Path & "\" & ªÑ²¼¥N½X & ".CSV")
- .Close
- End With
-
- Cells.Clear
- With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & ThisWorkbook.Path & "\" & ªÑ²¼¥N½X & ".CSV", Destination:=Range("$A$1"))
- .TextFileCommaDelimiter = True
- .Refresh BackgroundQuery:=False
- .Delete
- End With
-
- Kill ThisWorkbook.Path & "\" & ªÑ²¼¥N½X & ".CSV"
-
- End Sub
½Æ»s¥N½X |
|