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

[µo°Ý]VBA§ì¨ú.PHP­¶°ÝÃD??

¦^´_ 6# chen_cook

·PÁ chen_cook ¤j¤j¦^µª, ¦]¬OVBA·s¤â¦b¨Ï¥Î¤W¦³³\¦h¤£©ú¥Õ¦a¤è, ¦p¤è«K¸Ü¥i§_¤ñ·Ó1#,2# ªº¨Ò¤l.±NCODE ¶K¤W°Ñ¦Ò. TKS!!!

TOP

¦^´_ 5# tsuneng


    .Document.all("input_stock_code").Value = 6121  <--- stockscode$
     cells(1, 1) = stockcode$

TOP

½Ð°Ý¤j¤j, ¦p­n¬d¨ä¥LªÑ²¼,À³¦p¦ó­×§ï.TKS¡I¡I

TOP

¦^´_ 3# chen_cook

°£¤FVALUE¬OÄÝ©Ê¥~
    kn¡Bn¨Ã«D«O¯d¦r¡A³o¬OÅܼơA§A¦Û¤v¥i¥H³]¸m¥ô¦ó¦³·N¸qªº¦r¦ê¨ú¥N
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

·PÁ Hsieh ¤j¤j ¨ó§U¸Ñ¨M,ªì¨B´ú¸Õ§ì¨ì¤F..

          kn = n.Value    <==¦A½Ð±Ð³o¦æ¬O¦ó·N,VBA «O¯d¦r¶Ü??
         ¨ä¥¦¤j·§¬ÝªºÀ´.....

TOP

¥»©«³Ì«á¥Ñ Hsieh ©ó 2012-3-2 09:46 ½s¿è

¦^´_ 1# chen_cook

    With CreateObject("InternetExplorer.Application")
        .Visible = True
        .Navigate URL
        Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
        For Each n In .Document.getelementsbytagname("INPUT") '³o­Ó°j°é§ä¨ì«ö¶s¬O²Ä´X­Ó¿é¤J¶µ
           kn = n.Value
           If kn = "¬d¸ß" Then Exit For
           s = s + 1
        Next
        .Document.all("input_stock_code").Value = 6121 '­n¬dªº¥N½X
        .Document.getelementsbytagname("INPUT")(s).Click    '<=====¥¨¶°°õ¦æ¨ì¦¹´N¿ù»~,½Ð°Ý³o¤@¦æ¬O¬°¦ó·N,§ä¤F«Ü¤[¬d¤£¥X¬O¦ó·N
        Application.Wait Now + TimeValue("00:00:02") 'µ¥«Ý2¬í§ó·s¸ê®Æ
        Set tmp = .Document.getelementsbytagname("table")(79) '<==== (79)¤S¬O¦ó·N??79´Nªí¥Ü²Ä80­Óªí®æ
¦¹ºô­¶Â^¨ú½Ð´ú¸Õ
  1. Sub Macro1()
  2.     Dim i As Integer, j As Integer, k As Integer
  3. URL$ = "http://www.gretai.org.tw/ch/stock/statistics/monthly/st42.php"
  4.     With CreateObject("InternetExplorer.Application")
  5.         .Visible = True
  6.         .Navigate URL
  7.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  8.         For Each n In .Document.getelementsbytagname("INPUT") '³o­Ó°j°é§ä¨ì«ö¶s¬O²Ä´X­Ó¿é¤J¶µ
  9.            kn = n.Value
  10.            If kn = "¬d¸ß" Then Exit For
  11.            s = s + 1
  12.         Next
  13.         .Document.all("input_stock_code").Value = 6121 '­n¬dªº¥N½X
  14.         .Document.getelementsbytagname("INPUT")(s).Click    '«ö¤U¬d¸ß¯Ã
  15.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  16.         Application.Wait Now + TimeValue("00:00:02") 'µ¥«Ý2¬í§ó·s¸ê®Æ
  17.         Set tmp = .Document.all("rpt_result").getelementsbytagname("table")(2) 'Åã¥Ü°Ï²Ä3­Óªí®æ
  18.         k = 1
  19.         Cells(k, 1) = tmp.Rows(0).innertext
  20.         Cells(k, 1).WrapText = False
  21.         For i = 1 To tmp.Rows.Length - 1
  22.             k = k + 1
  23.             For j = 0 To tmp.Rows(i).all.Length - 1
  24.                 Cells(k, j + 1) = tmp.Rows(i).Cells(j).innertext
  25.             Next
  26.         Next
  27.         k = k + 1
  28.         Set tmp = .Document.all("rpt_result").getelementsbytagname("table")(3) 'Åã¥Ü°Ï²Ä4­Óªí®æ
  29.         For i = 0 To tmp.Rows.Length - 1
  30.             k = k + 1
  31.             For j = 0 To tmp.Rows(i).all.Length - 1
  32.                 Cells(k, j + 1) = tmp.Rows(i).Cells(j).innertext
  33.             Next
  34.             Next
  35.             .Quit
  36.         End With
  37. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

        ÀR«ä¦Û¦b : ¶¢¤HµL¼Ö½ì¡A¦£¤HµL¬O«D¡C
ªð¦^¦Cªí ¤W¤@¥DÃD