ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¦p¦ó¥Îvba¤U¸üÃÒ¥æ©Òºô­¶(¤é¦¬½L»ù¤Î¤ë¥­§¡¦¬½L»ù)¸ê®Æ

[µo°Ý] ¦p¦ó¥Îvba¤U¸üÃÒ¥æ©Òºô­¶(¤é¦¬½L»ù¤Î¤ë¥­§¡¦¬½L»ù)¸ê®Æ


­ì¥ý¥i¥Hª½±µ¥Îºô§}³sµ²¤è¦¡¤U¸ü
http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY_AVG/genpage/Report201602/201602_F3_1_8_2303.php?STK_NO=2303&myear=2016&mmon=01
¦Û2¤ë°_´NµLªk³sµ²
¦U¦ì¥ý¶i½Ð°Ý­n¦p¦ó½s¼gvba¥h¤U¸ü¹Ï¤ù¤¤¬õ¦â®Ø®Øªº¸ê®Æ
(ÃÒ¥æ©Òºô§}:http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY_AVG/STOCK_DAY_AVGMAIN.php)

¦^´_ 1# clianghot546
¸Õ¸Õ¬Ý
  1. Sub ­ÓªÑ¤é¦¬½L»ù¤Î¤ë¥­§¡»ùCSV()

  2.     Dim xml As Object
  3.     Dim stream
  4.     Dim URL As String
  5.     ¦~ = 2016
  6.     ¤ë = 2
  7.     ªÑ²¼¥N½X = 1101
  8.     Set xml = CreateObject("Microsoft.XMLHTTP") '¥Î¨Ó¨ú±oºô­¶¸ê®Æ
  9.     Set stream = CreateObject("ADODB.stream")   'ADODB.stream   '¥Î¨ÓÀx¦s¤G¶i¦ìÀÉ®×
  10.     URL = "http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY_AVG/STOCK_DAY_AVGMAIN.php"
  11.     xml.Open "POST", URL, 0
  12.     xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  13.     xml.send "download=csv&query_year=" & ¦~ & "&query_month=" & ¤ë & "&CO_ID=" & ªÑ²¼¥N½X
  14.     With stream
  15.         .Open
  16.         .Type = 1
  17.         .write xml.ResponseBody
  18.         'SaveToFile:ÀɮצWºÙ¤w¦s¦b®É·|¦³¿ù»~,¶·¥ý§R°£¤w¦s¦bªºÀɮצWºÙ
  19.         If Dir("D:\" & ªÑ²¼¥N½X & ".CSV") <> "" Then Kill "D:\" & ªÑ²¼¥N½X & ".CSV"
  20.         .SaveToFile ("D:\" & ªÑ²¼¥N½X & ".CSV")
  21.         .Close
  22.     End With
  23. End Sub
½Æ»s¥N½X

TOP

¦^´_ 2# joey0415
ÁÂÁÂjoey0415ªº¦^ÂÐ
¤w¸Õ¹L¥i¦æ
¦ý¬O¯à§_¦³ª½±µÃþ¦ü"±qweb"¤U¸ü«áª½±µ¶×¤JexcelÀx¦s®æªº»yªk

TOP

¦^´_ 3# clianghot546

¤U¸ücsv ¡A¶×¤J¦A§R°£§Y¥i
  1. Sub ­ÓªÑ¤é¦¬½L»ù¤Î¤ë¥­§¡»ùCSV()

  2.     Dim xml As Object
  3.     Dim stream
  4.     Dim URL As String
  5.     ¦~ = 2016
  6.     ¤ë = 2
  7.     ªÑ²¼¥N½X = 2498
  8.     Set xml = CreateObject("Microsoft.XMLHTTP") '¥Î¨Ó¨ú±oºô­¶¸ê®Æ
  9.     Set stream = CreateObject("ADODB.stream")   'ADODB.stream   '¥Î¨ÓÀx¦s¤G¶i¦ìÀÉ®×
  10.     URL = "http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY_AVG/STOCK_DAY_AVGMAIN.php"
  11.     xml.Open "POST", URL, 0
  12.     xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  13.     xml.send "download=csv&query_year=" & ¦~ & "&query_month=" & ¤ë & "&CO_ID=" & ªÑ²¼¥N½X
  14.     With stream
  15.         .Open
  16.         .Type = 1
  17.         .write xml.ResponseBody
  18.         'SaveToFile:ÀɮצWºÙ¤w¦s¦b®É·|¦³¿ù»~,¶·¥ý§R°£¤w¦s¦bªºÀɮצWºÙ
  19.         If Dir(ThisWorkbook.Path & "\" & ªÑ²¼¥N½X & ".CSV") <> "" Then Kill ThisWorkbook.Path & "\" & ªÑ²¼¥N½X & ".CSV"
  20.         .SaveToFile (ThisWorkbook.Path & "\" & ªÑ²¼¥N½X & ".CSV")
  21.         .Close
  22.     End With
  23.    
  24.     Cells.Clear

  25.     With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & ThisWorkbook.Path & "\" & ªÑ²¼¥N½X & ".CSV", Destination:=Range("$A$1"))
  26.         .TextFileCommaDelimiter = True
  27.         .Refresh BackgroundQuery:=False
  28.         .Delete
  29.     End With
  30.    
  31.     Kill ThisWorkbook.Path & "\" & ªÑ²¼¥N½X & ".CSV"
  32.    
  33. End Sub
½Æ»s¥N½X

TOP

¦^´_ 4# joey0415
ÁÂÁÂjoey0415ªº«ü±Ð
¥i¥H¥¿±`¹B§@¤F

TOP

¦^´_  clianghot546

¤U¸ücsv ¡A¶×¤J¦A§R°£§Y¥i
joey0415 µoªí©ó 2016-2-4 15:12


¦A½Ð±Ð
­ì¥ýªºvba½X¦bWIN7+OFFICE2010¥i¹B¦æ
¦bWIN10+OFFICE2016«o·|¥d¦b       .SaveToFile ("C:\Users1\CYUser\Downloads" & "\" & ªÑ²¼¥N½X & ".CSV")
¦p¤U¹Ï

TOP

¦^´_ 6# clianghot546
  1. C:\Users1\CYUser\Downloads" & "\" & ªÑ²¼¥N½X & ".CSV")
½Æ»s¥N½X
§Úªºµ{¦¡½X¨S¦³³o­Ó®@¡I

C:\Users1\CYUser\Downloads

¸ô®|¤£¹ï®@

TOP

¦^´_ 6# clianghot546

    WIN10+OFFICE2016«o·|¥d¦b       .SaveToFile ("C:\Users1\CYUser\Downloads" & "\" & ªÑ²¼¥N½X & ".CSV")

WIN10+OFFICE2016 ªºpc¸Ì¦³³o¸ê®Æ§¨¶Ü?

¸Õ¸Õ¬Ý «Ø¥ß¸ê®Æ
  1. Option Explicit
  2. Sub Ex()
  3.     Dim xPath As String, i As Integer, S As String
  4.     xPath = "C:\Users1\CYUser\Downloads"
  5.     For i = 2 To UBound(Split(xPath, "\"))
  6.         S = Mid(xPath, 1, InStr(xPath, Split(xPath, "\")(i)) - 1)
  7.         If Dir(S, vbDirectory) = "" Then MkDir S
  8.    Next
  9.    If Dir(xPath, vbDirectory) = "" Then MkDir xPath
  10.    MsgBox Dir(xPath, vbDirectory)
  11. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 7# joey0415
joey0415
®Ú¾Ú±zªº¦^ÂЧڦ³µy§@­×§ï¥H®M¥Î¦b§Úªº¹q¸£
­Y¦³«_¥Ç½Ð¨£½Ì

TOP

¦^´_ 8# GBKEE
ÁÂÁÂGBKEE¦^ÂÐ
¤µ¤éªá®É¶¡±qÀY¬Ý¤@¹M«áµo²{¦³¤@³B¸ô®|¥¼­×§ï§¹¥þ
²{¦b¥i¥¿±`¹B§@¤F

TOP

        ÀR«ä¦Û¦b : ¡i®É¶¡¦¨´N¤@¤Á¡j®É¶¡¥i¥H³y´N¤H®æ¡A¥i¥H¦¨´N¨Æ·~¡A¤]¥i¥HÀx¿n¥\¼w¡C
ªð¦^¦Cªí ¤W¤@¥DÃD