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

[µo°Ý] ºô¸ôCSV¤U¸ü°ÝÃD

¥»©«³Ì«á¥Ñ spermbank ©ó 2013-3-30 00:58 ½s¿è

¦^´_ 2# GBKEE


    ·l¯qªí¤W¥«¤Î¤WÂd¥i¥H­C¡A¤Q¤À·PÁ¤j¤j
    ¥t¥~§Ú§âºô§}§ï¦¨http://mops.twse.com.tw/mops/web/t51sb13 Ū¨ú¦X¨Ö·l¯qªí  
    §Úµo²{«o¤S¤£¦æÅo¡A¤£ª¾¹D­n¦p¦ó­×¸Ó?
    ­Yºô¸ô¸ê®Æ·|³°Äò¼W¥[µ§¼Æ¡A¬O§_»Ý­n¦Û¦æ§ó·s§PÂ_µ§¼Æ©O?
    ÁÂÁÂ

TOP

RE: ºô¸ôCSV¤U¸ü°ÝÃD

¦^´_ 1# spermbank
³o­ì©lÀɮפ¤§ä¤£¨ìCSVÀɮתººô§}¥i¤U¸ü!!
¸Õ¸Õ¬Ý (¥i¸ÕµÛ­×§ï¤U¸ü¤W¥«,¤WÂdªº¸ê®Æ)
  1. Option Explicit
  2. Sub ¤½¶}¸ê°TÆ[´ú¯¸()
  3.     Dim Ie As Object, xx, k, j, i, AA As Variant
  4.     Dim T As Date
  5.     ActiveSheet.Cells.Clear
  6.      Application.DisplayStatusBar = True
  7.     On Error GoTo ie_err
  8.     Set Ie = CreateObject("InternetExplorer.Application")
  9.     Ie.Navigate "http://mops.twse.com.tw/mops/web/t51sb08"
  10.     Ie.Visible = True
  11.     Do While Ie.Busy Or Ie.ReadyState <> 4: DoEvents: Loop
  12.     '**********  ­×§ï³o¸Ì ªº¿ï¶µ
  13.     Ie.Document.ALL(632).Value = "sii"   '¤W¥« = sii,¤WÂd = otc,¿³Âd = rotc,¤½¶}µo¦æ = pub
  14.     Ie.Document.ALL(643).Value = "101"   '¦~«×
  15.     Ie.Document.ALL(650).Value = "04"    '²Ä¤@©u = 01,²Ä¤G©u = 02,²Ä¤T©u = 03,²Ä¥|©u = 04
  16.     Ie.Document.ALL(667).Click
  17.    
  18.     Ie.Visible = False
  19.     ºô­¶¾ã²z
  20.     Set AA = Ie.Document.getelementsbytagname("table")   '¸ê®Æ°Ï
  21.    ' Ie.Quit
  22.     T = Time
  23.     Application.ScreenUpdating = False
  24.     With ActiveSheet
  25.         On Error Resume Next
  26.         For xx = 13 To AA.Length - 1
  27.             For i = 0 To AA(xx).Rows.Length - 1      '¼g¤J¸ê®Æ
  28.                 k = k + 1
  29.                 For j = 0 To 19
  30.                     .Cells(k, 1).Select
  31.                     Application.StatusBar = "¤U¸ü¸ê®Æ¤¤ ..." & k - 1
  32.                     .Cells(k, j + 1) = AA(xx).Rows(i).Cells(j).innertext
  33.                 Next
  34.             Next
  35.         Next
  36.         Set AA = .Range("S2:S" & .[S2].End(xlDown).Row)
  37.         AA.Replace "°ò¥»¨CªÑ¬Õ¾l", "", xlWhole
  38.         AA.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
  39.         .Cells(.Rows.Count, 1).End(xlUp).EntireRow.Delete
  40.          ActiveWindow.ScrollRow = .Cells(.Rows.Count, 1).End(xlUp).Row - 20
  41.         .Cells(.Rows.Count, 1).End(xlUp).Select
  42.     End With
  43.     Application.ScreenUpdating = True
  44.     'Ie.Quit
  45.     Application.StatusBar = "¤U¸ü¸ê®Æ®É¶¡ : " & Format(Time - T, ["S¬í"])
  46.     End
  47. ie_err:
  48.     MsgBox "ºô­¶¦³°ÝÃD,½Ð­«·s°õ¦æ..."
  49.     Set Ie = Nothing
  50. End Sub
  51. Private Sub ºô­¶¾ã²z()   'µ¥«Ýºô­¶¤U¸ü¸ê®Æ§¹²¦ªº®É¶¡
  52.     Dim Tt(1 To 3) As Date
  53.     Tt(1) = Time
  54.     Tt(2) = Time
  55.     Tt(3) = #12:00:10 AM#     '10¬í ½Õ¾ã³o¸Ì
  56.     Do
  57.         If Time > Tt(2) Then
  58.             Application.StatusBar = "ºô­¶¤U¸ü¤¤ ³Ñ¾l¬í¼Æ.. " & Second(Tt(1) + Tt(3) - Time)
  59.             Tt(2) = Time
  60.         End If
  61.         DoEvents
  62.     Loop Until Time > Tt(1) + Tt(3)
  63.     Application.StatusBar = "¸ê®Æ¤U¸ü¤¤...."
  64. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : µoµÊ®ð¬Oµu¼ÈªºµoºÆ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD