ªð¦^¦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 : ¤@¥y·Å·xªº¸Ü¡A´N¹³©¹§O¤H¨­¤WÅx­»¤ô¡A¦Û¤v·|ªg¨ì¨â¤Tºw¡C
ªð¦^¦Cªí ¤W¤@¥DÃD