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

½Ð°Ý¦p¦ó±Nºô­¶ªº¹Ï¤ù¦sÀÉ

¦^´_ 14# GBKEE



½Ð°Ý,¸Ó¦p¦ó¸ü¤J¨ä¥L­¶¦¸
­Y¤£¥Î¼g¤JExcel,¦Óª½±µ .Click ¤U¸üCSVÀÉ(BIG5) ÀÉ®×
»yªk¸Ó«ç»ò­×¥¿
  1.         Set aa = .Document.getElementsByTAGName("INPUT")
  2.         For R = 0 To aa.Length - 1
  3.             If aa(R).Value = "¤U¸üCSVÀÉ(BIG5)" And aa(R).Type = "button" Then
  4.                 aa(R).Click   '¦³ "¤U¸üCSVÀÉ(BIG5)" ªº«ö¶s
  5.                     Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  6.             End If
  7.         Next
½Æ»s¥N½X

TOP

¦^´_ 19# GBKEE

­C!¦¨¤F

ÁÂÁ±zªº«ü¾É¡I
µ{¦¡»y¨¥¡A³Õ¤jºë²`
¹ï§Ú¨Ó»¡«ÜÁ}Ãø¡A¦]¬°¦n¥Î¡AÁÙ¬O«Ü§V¤OªººÉ¶q¦h§l¦¬¤@¨Ç
ÁÙ¨S¬ÝÀ´ªº³¡¤À¡A¤]¥ý¦¬¶°°_¨Ó¡A«Ý¤é«á®ø¤Æ

~·P®¦~

TOP

¦^´_ 21# joey0415

¾ã¬q»yªk¬O³o¼Ëªº , ºî¦X #2 & #9
ThisWorkbook¼Ò²Õªºµ{¦¡½X
  1. Option Explicit
  2. Private Sub Workbook_Open()
  3.     Sheet1.Msg = True
  4.     Run "Sheet1.¹Ï§Î§ó·s"
  5. End Sub
  6. Private Sub Workbook_BeforeClose(Cancel As Boolean)
  7.     On Error Resume Next
  8.     If Not Sheet1.IE Is Nothing Then Sheet1.IE.Quit
  9. End Sub
½Æ»s¥N½X
Sheet1¼Ò²Õªºµ{¦¡½X
  1. Option Explicit
  2. Public IE As Object, Msg As Boolean, IEx As Object
  3. Const ¹Ï§Î = "C:\ÅçÃÒ¹Ï.jpg"
  4. Const ÃÒ¨é¥N¸¹ = "F2"
  5. Const ÅçÃÒ½X = "F4"
  6. Private Sub Worksheet_Change(ByVal Target As Range)
  7.     Range(ÃÒ¨é¥N¸¹).Interior.ColorIndex = IIf(Range(ÃÒ¨é¥N¸¹).Value = "", 2, 36)
  8.     With Target.Cells(1)
  9.          If .Address(0, 0) = ÅçÃÒ½X Then .Interior.ColorIndex = IIf(Len(Trim(.Cells)) = 5, 36, 2)
  10.          If .Address(0, 0) = ÅçÃÒ½X And Len(Trim(.Cells)) = 5 And Range(ÃÒ¨é¥N¸¹).Value <> "" Then
  11.             If IE Is Nothing Then
  12.                 Target = ""
  13.                 Msg = True
  14.                 ¹Ï§Î§ó·s
  15.                 Exit Sub
  16.             End If
  17.             Application.EnableEvents = False
  18.             ¤é³øªí¸ü¤J
  19.             Target = ""
  20.             Application.EnableEvents = True
  21.         End If
  22.     End With
  23. End Sub
  24. Private Sub ¤é³øªí¸ü¤J()
  25.     Dim e As Object, A As Object, k  As Integer, i As Integer, S As String
  26.     If IE Is Nothing Then
  27.         ¹Ï§Î§ó·s
  28.         MsgBox "ÅçÃҹϤw§ó·s"
  29.         Exit Sub
  30.     End If
  31.     With IE
  32.         .Document.all.tags("INPUT")("stk_code").Value = Range(ÃÒ¨é¥N¸¹)
  33.         .Document.all.tags("INPUT")("auth_num").Value = Trim(Range(ÅçÃÒ½X))
  34.         Set A = .Document.all.tags("BUTTON")
  35.         For Each e In A
  36.             If Trim(e.Innertext) = "¬d¸ß" And e.ID = "" Then
  37.             e.Click
  38.             Exit For
  39.             End If
  40.         Next
  41.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  42.         UsedRange.Offset(6).Clear
  43.         Range("a" & k + 1) = S
  44.         If .Document.body.Innertext Like "***¸ÓªÑ²¼¸Ó¤éµL¥æ©ö¸ê°T***" Then S = "***¸ÓªÑ²¼¸Ó¤éµL¥æ©ö¸ê°T***"
  45.         If .Document.body.Innertext Like "***ÅçÃÒ½X¿ù»~¡A½Ð­«·s¬d¸ß¡C***" Then S = "***ÅçÃÒ½X¿ù»~¡A½Ð­«·s¬d¸ß¡C*** "
  46.         If S <> "" Then
  47.             Range("a" & k + 1) = S
  48.             MsgBox S
  49.             GoTo NN
  50.         End If
  51.         Set IEx = CreateObject("InternetExplorer.Application")
  52.         IEx.Navigate "about:Tabs"
  53.         Set A = .Document.all.tags("A")
  54.         ³æ­¶¸ü¤J .Document.all.tags("table")(0).outerHTML
  55.         [A6].Select
  56.         '********µ{¦¡½X¼g¦b¤u§@ªí¼Ò²Õ: Me «ü³o¤u§@ªí¼Ò²Õ
  57.         Me.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
  58.         '****************************************
  59.         If A.Length = 459 Then
  60.             For i = 2 To 3
  61.                 ³æ­¶¸ü¤J .Document.all.tags("table")(i).outerHTML
  62.                 With Range("A" & Rows.Count).End(xlUp).Offset(1)
  63.                     .Select
  64.                     Me.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
  65.                 End With
  66.             Next
  67.         Else
  68.             For k = 0 To A.Length - 1
  69.                 If Val(A(k).Innertext) >= 1 Then
  70.                     Debug.Print A(k).Innertext
  71.                     A(k).Click
  72.                     Do While .Busy Or .readyState <> 4: DoEvents: Loop
  73.                     Set A = .Document.all.tags("A")
  74.                     Do While .Busy Or .readyState <> 4: DoEvents: Loop
  75.                     For i = 2 To 3
  76.                         ³æ­¶¸ü¤J .Document.all.tags("table")(i).outerHTML
  77.                         With Range("A" & Rows.Count).End(xlUp).Offset(1)
  78.                             .Select
  79.                             Me.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
  80.                         End With
  81.                     Next
  82.                 End If
  83.             Next
  84.         End If
  85.         IEx.Quit
  86.         Set IEx = Nothing
  87.         ¾ã²z
  88. NN:
  89.         .Quit
  90.     End With
  91.     Set IE = Nothing
  92.     ¹Ï§Î§ó·s
  93. End Sub
  94. Private Sub ³æ­¶¸ü¤J(S)
  95.     With IEx
  96.         .Document.body.innerHTML = S
  97.         .ExecWB 17, 2       '  Select All
  98.         .ExecWB 12, 2       '  Copy selection
  99.     End With
  100. End Sub
  101. Private Sub ¾ã²z()
  102.     On Error Resume Next
  103.     Application.EnableEvents = False
  104.     With UsedRange.Offset(10)
  105.         .Replace "§Ç¸¹", "=ex", xlWhole
  106.         .SpecialCells(xlCellTypeFormulas, xlErrors).EntireRow.Delete
  107.     End With
  108.     UsedRange(1).Select
  109.     Application.EnableEvents = True
  110. End Sub
  111. Private Sub Get_Ie()
  112.     Set IE = CreateObject("InternetExplorer.Application")
  113.     With IE
  114.        ' .Visible = True
  115.         '¨é°Ó¶R½æÃÒ¨é¤é³øªí¬d¸ß¨t²Î¡]¤@¯ë¥æ©ö¡^
  116.         .Navigate "http://www.gretai.org.tw/web/stock/aftertrading/broker_trading/brokerBS.php?l=zh-tw"
  117.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  118.     End With
  119. End Sub
  120. Private Sub ¹Ï§Î§ó·s()
  121.     If IE Is Nothing Then Get_Ie
  122.     If Msg Then MsgBox "ÅçÃÒ¹Ï §ó·s§¹²¦"
  123.     Msg = False
  124.     With IE
  125.         .Refresh
  126.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  127.         ºô¸ô¹Ï¤ù¦sÀÉ .Document.all.tags("IMG")(0).href
  128.     End With
  129.     Sheet1.Shapes("ÅçÃÒ¹Ï").Fill.UserPicture ¹Ï§Î    '
  130. End Sub
  131. Private Sub ºô¸ô¹Ï¤ù¦sÀÉ(img As String)
  132.     Dim xml As Object     '¥Î¨Ó¨ú±oºô­¶¸ê®Æ
  133.     Dim stream            'As ADODB.stream   '¥Î¨ÓÀx¦s¤G¶i¦ìÀÉ®×
  134.     Set xml = CreateObject("Microsoft.XMLHTTP")
  135.     Set stream = CreateObject("ADODB.stream")
  136.     xml.Open "GET", img, 0
  137.     xml.send
  138.     With stream
  139.         .Open
  140.         .Type = 1
  141.         .write xml.ResponseBody
  142.         If Dir(¹Ï§Î) <> "" Then Kill ¹Ï§Î
  143.         .SaveToFile (¹Ï§Î)
  144.         .Close
  145.     End With
  146. End Sub
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ HSIEN6001 ©ó 2014-12-16 15:06 ½s¿è

¦^´_ 19# GBKEE

±z¦n,§Ú¤w¸g§ä¨ìCSV¤U¸üªº°Ñ¼Æ
GET
URL = "http://www.gretai.org.tw/web/stock/aftertrading/broker_trading/download_ALLCSV.php?curstk=" & ÃÒ¨é¥N¸¹ & "&stk_date=" & ¤é´Á & "&auth=" & ÅçÃÒ½X

§Ú§âªí¨­¶×¤J§ï¦¨³o¬q
  1.     Dim xml As Object     '¥Î¨Ó¨ú±oºô­¶¸ê®Æ
  2.     Dim stream            'As ADODB.stream   '¥Î¨ÓÀx¦s¤G¶i¦ìÀÉ®×
  3.     Set xml = CreateObject("Microsoft.XMLHTTP")
  4.     Set stream = CreateObject("ADODB.stream")

  5. Dim path As String, url
  6. path = "C:\"
  7.     Dim ¤é´Á As String
  8.     ¤é´Á = "1031215"

  9. 'GET http://www.gretai.org.tw/web/stock/aftertrading/broker_trading/download_ALLCSV.php?curstk=ªÑ²¼¥N¸¹&stk_date=¤é´Á&auth=ÅçÃÒ½X

  10.     url = "http://www.gretai.org.tw/web/stock/aftertrading/broker_trading/download_ALLCSV.php?curstk=" & Sheets("Sheet1").[F2] & "&stk_date=" & ¤é´Á & "&auth=" & Sheets("Sheet1").[F4]
  11.         xml.Open "GET", url, 0
  12.         xml.send
  13.     With stream
  14.         .Type = 1
  15.         .Open
  16.         .write xml.responseBody
  17.         If Dir(path & Sheets("Sheet1").[F2] & ".csv") <> "" Then Kill (path & Sheets("Sheet1").[F2] & ".csv")
  18.         .SaveToFile (path & Sheets("Sheet1").[F2] & ".csv")
  19.         .Close
  20.     End With
½Æ»s¥N½X
«D±`ÁÂÁ±zªº«ü¾É!!
^__^

TOP

¦^´_ 25# flask

   .Columns("A:A").TextToColumns Destination:=.Range("A1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
        Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
        :=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
        Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1)), _
        TrailingMinusNumbers:=True

    ½Ð°Ý³o¬q«ç»òÀ³¥Î,§Ú¤]·Q­nzipÀÉ
¥i§_µ¹°Ñ¦Ò,ÁÂÁÂ

TOP

¦^´_ 24# joey0415

¦sÀɦì¸m¦Û¦æ­×¥¿
°Ñ¦Ò!
    ¤U¸üCSV.rar (10 KB)

TOP

¦^´_ 25# flask

§Ú¤w¸g¬ÝÀ´¤F,¤Ó¼F®`¤F
¯uªº«Ü§Ö!!ÁÂÁÂ

TOP

¦^´_ 29# GBKEE

ª©¤j Workbook open ¶×¤JCSVªº¤è¦¡ , ¦¬¤UÅo!ÁÂÁÂ~

TOP

¦^´_ 29# GBKEE
±z¦n,³o¸Ì¤@ª½¥X²{¯Ê With ¤£ª¾¹D­þ¸Ì­n­×§ï
³Â·ÐÀ°¦£®Õ¥¿°ÝÃD
  1. Sub ¤U¸üCSV()
  2. Dim path As String, ¤é´Á As String, URL As String, ¥N¸¹
  3. path = "C:\myStock\"
  4. ¤é´Á = Format(Date, "emmdd")
  5. Dim Rng As Range
  6. AA:
  7.     Set Rng = [C:C].Find("NG", , , xlWhole)
  8.     Sheets("¤U¸ü¨Ì¾Ú").Activate
  9.     With CreateObject("InternetExplorer.application")
  10.         .Visible = True
  11.         .navigate "http://www.gretai.org.tw/web/stock/aftertrading/broker_trading/brokerBS.php?l=zh-tw"
  12.             Do Until .readyState = 4
  13.                 DoEvents
  14.             Loop
  15.         ÅçÃÒ½X = InputBox("¿é¤J¬d¸ßÅçÃÒ½X", "ÅçÃÒ½X", code)   'ÅçÃÒ½X = InputBox
  16.         For Each ¥N¸¹ In Range(Rng.Offset(0, -2), [E65536].End(xlUp))
  17.             .document.all("stk_code").Value = ¥N¸¹
  18.             .document.all("auth_num").Value = ÅçÃÒ½X
  19.         '**** ª½±µ¤U¸üCSV ****
  20.         Dim xml As Object
  21.         Dim stream
  22.         Set xml = CreateObject("Microsoft.XMLHTTP")
  23.         Set stream = CreateObject("ADODB.stream")
  24.             'GET http://www.gretai.org.tw/web/stock/aftertrading/broker_trading/download_ALLCSV.php?curstk=8069&stk_date=1031215&auth=ÅçÃÒ½X
  25.             URL = "http://www.gretai.org.tw/web/stock/aftertrading/broker_trading/download_ALLCSV.php?curstk=" & ¥N¸¹ & "&stk_date=" & ¤é´Á & "&auth=" & ÅçÃÒ½X
  26.                 xml.Open "GET", URL, 0
  27.                 xml.send
  28.             With stream
  29.                 .Type = 1
  30.                 .Open
  31.                 .write xml.responseBody
  32.                 '**** §PÂ_Ū¨ú¸ê®Æ   ****************************************************************
  33.                 If .document.body.Innertext Like "*¸Ó¤éµL¥æ©ö¸ê°T*" Then
  34.                     GoTo NN  'Goto ¤U¤@­Ó
  35.                 ElseIf .document.body.Innertext Like "*ÅçÃÒ½X¿ù»~¡A½Ð­«·s¬d¸ß*" Then
  36.                     Sheets("¤U¸ü¨Ì¾Ú").Range("C:C").Delete      '²M°£ÂªºNG°O¸¹
  37.                     ¥N¸¹.Offset(, 2) = "NG"                     '·s¼WÂ_ÂI
  38.                     .Quit   'Ãö³¬ IE µøµ¡
  39.                     GoTo AA
  40.                  ElseIf .document.body.Innertext Like "*ÅçÃÒ½X¤w¹O´Á¡A½Ð­«·s¬d¸ß*" Then
  41.                     Sheets("¤U¸ü¨Ì¾Ú").Range("C:C").Delete      '²M°£ÂªºNG°O¸¹
  42.                     ¥N¸¹.Offset(, 2) = "NG"                     '·s¼WÂ_ÂI
  43.                     .Quit   'Ãö³¬ IE µøµ¡
  44.                     GoTo AA
  45.                 '***** §PÂ_Ū¨ú¸ê®Æ  End *************************************************************
  46.                 .SaveToFile (path & ¥N¸¹ & ".csv")
  47.                 .Close
  48.             End With
  49. NN:
  50.     Next
  51.         .Quit   'Ãö³¬ IE µøµ¡
  52.     End With
  53.     Range("C2") = "NG"  '­«·s§@°O¸¹,¤è«K¤U¦^¤U¸ü
  54. End Sub
½Æ»s¥N½X

TOP

¦^´_ 33# GBKEE


    ¥X²{°õ¦æ¶¥¬q¿ù»~'438 , ª«¥ó¤£¤ä´©¦¹ÄݩʩΤèªk
¸ò³o¤@¬q§PÂ_¦¡¦³Ãö,¤£ª¾¹D¸Ó«ç»ò§ï ?
¨S§PÂ_¤º®e,·|¤U¸ü¨ìªÅ­È
  1.                 .write xml.responseBody
  2.                 '**** §PÂ_Ū¨ú¸ê®Æ   ****************************************************************
  3.                 If .document.body.Innertext Like "*¸Ó¤éµL¥æ©ö¸ê°T*" Then
  4.                     GoTo NN  'Goto ¤U¤@­Ó
  5.                 ElseIf .document.body.Innertext Like "*ÅçÃÒ½X¿ù»~¡A½Ð­«·s¬d¸ß*" Then
  6.                      '¥N¸¹.Offset(, 2) = "NG"
  7.                      GoTo AA ''µøµ¡¤£Ãö³¬ & ­«·s¿é¤JÅçÃÒ½X & ¥N¸¹
  8.                 ElseIf .document.body.Innertext Like "*ÅçÃÒ½X¤w¹O´Á¡A½Ð­«·s¬d¸ß*" Then
  9.                     Sheets("¤U¸ü¨Ì¾Ú").Range("F:F").Delete      '²M°£ÂªºNG°O¸¹
  10.                     ¥N¸¹.Offset(, 1) = "NG"                     '¦b¹j¾À ²Ä1Äæ¦ì¼Ðµù "NG" , ¤è«K­«·s§ì¨ú®É,Á×¶}¤w¸g¤U¸üªº¸ê®Æ
  11.                     .Quit   'Ãö³¬ IE µøµ¡
  12.                      GoTo AA ''µøµ¡­«·s¶}±Ò & ­«·s¿é¤JÅçÃÒ½X & ¥N¸¹
  13.                 End If
  14.                 '***** §PÂ_Ū¨ú¸ê®Æ  End *************************************************************
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¦a¤WºØ¤Fµæ¡A´N¤£©öªø¯ó¡F¤ß¤¤¦³µ½¡A´N¤£©ö¥Í´c¡C
ªð¦^¦Cªí ¤W¤@¥DÃD