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

½Ð±Ð¦³ÃöADODB.STREAM©MMicrosoft.XMLHTTPªº¥Îªk

¦^´_ 5# ¤p«L«È
§A¤w¦³¿n¤À44¤À  ª©³W: Àɮתþ¥ó­­µ¥¯Å¤¤¾Ç¥Í¡]¿n¤À50¡^¥H¤W¤~¯à¤U¸ü
¥[ªo ¥[ªo!

TOP

¦^´_ 3# GBKEE


    Áª©¤j¡A¥i¬O§ÚÅv­­¤£°÷¡A¤£¯à¤U¸ü©O
¥t¥~¡A¥i¥H¤¶²ÐStreamªº¥Îªk¶Ü¡H¦n¹³¤£©ö²z¸Ñ.....

TOP

¦^´_ 2# HSIEN6001


ÁÂÁ§Aªº«ü±Ð¡A¬Ý°_¨Ó§A¼gªºCODE¤ñ§Ú¤u¾ã¦h¤F¡C
¦ý§Ú¬Ý¨ì§A¦n¹³§â§Úªºcode¤À¦¨¤T³¡¥÷¡A²Ä¤@­Ó©R¥O¬O·í¶}³o­ÓEXCEL FILE®É±Ò°Ê
¤§«á¦b"Microsoft.XMLHTTP"³¡¥÷Ū¨úCSV¡A¥ýÀˬdÀɮ׬O§_¦s¦b¡A¦p¦s¦b«K¥ý§R±¼¦A«Ø¥ß¤@­Ó·sªº(³o­Ó¤Ó¦n¤F¡A²{®É§Ú¬O¤â°Ê§R°£ªº¡AÁÂÁÂ)
µM«á¥ÎEXCEL VBA CALL ACCESS¦æMODULE¡A¹ï¶Ü¡H

¦ý·í¤¤¦³¨â­Ó°ÝÃD¡A¥Ñ©óYAHOO´£¨ÑªºCSV¨S¦³ªÑ²¼½s¸¹¡A¦pªG¤£¦b¼g¤JACCESS®É¥[¤W«KµLªk½T»{³o­ÓRECORD¬O¨º¥uªÑ²¼
¥t¥~¡A³o­Ó¼gªkÁÙ¬O»Ý­n¡AŪ¨úYAHOO¸ê®Æ>Àx¦s¦¨CSV>Ū¨úCSV>¼g¤JACCESS>§R°£CSV
§Ú¤W­±ªºCODE¡A¨ä¹ê¬O¥i¥H°µ¨ìªº¡A¦ý§Ú§Æ±æ·í¥Î"Microsoft.XMLHTTP"Ū¨úYAHOO¸ê®Æ®É¡A¯à°÷¤£¥ÎÀx¦s¦¨CSV¡Aª½±µ§â¸ê®Æ¼g¨ìACCESS¤¤¡A¤£¥Î¤£Â_­«½Æ«Ø¥ß©M§R°£CSV(¦]¬°§Ú·|§ì¼Æ¦Ê¶¡¤½¥q¸ê®Æ)¡C

TOP

¦^´_ 1# ¤p«L«È
¸Õ¸Õ¬Ý

test.rar (224.78 KB)

TOP

¦^´_ 1# ¤p«L«È

¸Õ¸Õ!
Excel VBA¡G
ThisWorkbook¶K¤W
  1. Private Sub Workbook_Open()
  2.     SaveCSV
  3.     AccessModule
  4.     Kill "D:\Sharestemp01\shareNo.csv"
  5. End Sub
½Æ»s¥N½X
Excel Module¡G¶K¤W
  1. Sub SaveCSV()
  2. Dim xml As Object
  3. Dim stream
  4. Dim URL As String
  5. Dim path As String
  6. path = "D:\Sharestemp01\"

  7. Set xml = CreateObject("Microsoft.XMLHTTP")
  8. Set stream = CreateObject("ADODB.stream")
  9.     URL = "http://ichart.finance.yahoo.com/table.csv?s=" & "shareNo" & ".HK&a=09&b=27&c=2001&d=07&e=29&f=2012&g=d&ignore=.csv"
  10.         xml.Open "GET", URL, 0
  11.         xml.send
  12.     With stream
  13.         .Type = 1
  14.         .Open
  15.         .Write xml.responseBody
  16.         If Dir(path & "shareNo" & ".csv") <> "" Then Kill (path & "shareNo" & ".csv")
  17.         .SaveToFile (path & "shareNo" & ".csv")
  18.         .Close
  19.     End With
  20. Set stream = Nothing
  21. Set xml = Nothing
  22. End Sub

  23. Sub AccessModule()
  24. Dim A As Object
  25. Application.DisplayAlerts = False
  26. Set A = CreateObject("Access.Application")
  27.         A.Visible = False
  28.         A.OpenCurrentDatabase filepath:="D:\Shares\temp.mdb", Exclusive:=False, bstrPassword:=""
  29.         A.Run "InPutData"
  30.     Application.DisplayAlerts = True
  31.     A.CloseCurrentDatabase
  32.     A.Quit
  33. Set A = Nothing
  34. End Sub
½Æ»s¥N½X
Temp.mdb ·s¼WModule¡G¶K¤W
  1. Option Compare Database

  2. Function InPutData()
  3.     DoCmd.SetWarnings False
  4.     DoCmd.TransferText acImportDelim, "", "Table", "D:\Sharestemp01\shareNo.csv", True, ""
  5. End Function
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¤p¨Æ¤£°µ¡B¤j¨ÆÃø¦¨¡C
ªð¦^¦Cªí ¤W¤@¥DÃD