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

VBA POST §ìÃÒ¥æ©Ò ¨C¤é¦¬½L¦æ±¡(¥þ³¡(¤£§tÅvÃÒ¡B¤ûºµÃÒ)

VBA POST §ìÃÒ¥æ©Ò ¨C¤é¦¬½L¦æ±¡(¥þ³¡(¤£§tÅvÃÒ¡B¤ûºµÃÒ)

¸Õ¸Õ¬Ý~¦³§ó¦nªº¤èªk½Ð¤j®a¤@°_°Q½×~

­n¦³¤u§@ªí WW..¨Ã¦b A1 ¤W¦³¤é´Á¦p 2015/01/05
¦A«Ø¤@­Ó¤u§@ªí dd...


Sub XL()
Dim wt As Date
wt = Sheets("ww").Range("A1").Value
xt = Format(wt, "E/MM/DD")
gt = Format(wt, "E-MM-DD")

Set XML = CreateObject("Microsoft.XMLHTTP")
Set stream = CreateObject("ADODB.stream")
Dim path As String, thePOSTdata, URL
path = "C:\"

Set sh = Sheets("dd")
  Sheets("dd").Activate
Worksheets("dd").UsedRange.Offset(0).Clear


    URL = "http://www.twse.com.tw/ch/trading/exchange/MI_INDEX/MI_INDEX.php"
    thePOSTdata = "download=csv&qdate=" & xt & "&selectType=ALLBUT0999"
        XML.Open "POST", URL, 0
        XML.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
        XML.send thePOSTdata
    With stream
        .Open
        .Type = 1
        .write XML.responseBody
         
           
        
        If Dir(path & "¦¬½L" & gt & ".csv") <> "" Then Kill (path & "¦¬½L" & gt & ".csv")
        .SaveToFile (path & "¦¬½L" & gt & ".csv")
        .Close
    End With

With Workbooks.Open(path & "¦¬½L" & gt & ".csv")
          .Sheets(1).UsedRange.Offset(117, 0).Copy sh.[a1]
          .Close 0
     End With


End Sub

§Ú¤]ÆZ·Qª¾¹Dªº
«ç»ò¤£¥Î¤@­Óºô­¶¦³³o¨Ç¸ê®Æ´N¦n¤F ¥Îºô­¶§ì
¯u¬O ·Ð¦º¤F

TOP

        ÀR«ä¦Û¦b : ¡i¥Í©R¦b©I§l¶¡¡j¦òªû»¡¡G¡u¥Í©R¦b©I§l¶¡¡C¡v¤HµLªkºÞ¦í¦Û¤vªº¥Í©R¡A§óµLªk¾×¦í¦º´Á¡AÅý¦Û¤v¥Ã¦í¤H¶¡¡C¬JµM¥Í©R¥h¨Ó³o»òµL±`¡A§Ú­Ì§óÀ³¸Ó¦n¦n¦a·R±¤¥¦¡B§Q¥Î¥¦¡B¥R¹ê¥¦¡AÅý³oµL±`¡BÄ_¶Qªº¥Í©R¡A´²µo¥¦¯uµ½¬üªº¥ú½÷¡A¬M·Ó¥X¥Í©R¯u¥¿ªº»ù­È¡C
ªð¦^¦Cªí ¤W¤@¥DÃD