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

½Ð°Ý³o­Óºô­¶¦p¦ó¥ÎWEB¬d¸ß¿é¤Jexcel

¦^´_ 45# joey0415
°Ñ¦Ò¡G
  1. Sub ¹d¨Éºô()
  2.     Dim URL As String, shts As Worksheet
  3.     Dim x As Variant, xi As Integer
  4.    
  5.     Set shts = Sheets("¤u§@ªí2")
  6.     URL = "http://www.cnyes.com/twstock/Institutional/1101.htm"
  7.    
  8.     With CreateObject("InternetExplorer.Application")
  9.         .Visible = True     '  ¬O§_Åã¥Ü IE
  10.         .Navigate URL
  11.         
  12.         shts.Cells.Clear
  13.         For xi = 1 To 6
  14.             Do While .readyState <> 4 Or .Busy
  15.                 DoEvents
  16.             Loop
  17.             
  18.             For Each x In .document.getElementsBytagname("input")
  19.                 If x.Value = "¬d¸ß" Then x.Click: Exit For
  20.             Next
  21.             
  22.             .document.body.innerHTML = .document.getElementsBytagname("table")(xi).outerHTML
  23.             .execwb 17, 2       '  Select All
  24.             .execwb 12, 2       '  Copy selection
  25.             
  26.             With shts
  27.                 .Range("A" & .[A65535].End(xlUp).Row + 1).Select
  28.                 .PasteSpecial Format:="HTML"
  29.             End With
  30.         Next xi
  31.         shts.Cells.EntireColumn.AutoFit     '  ¦Û°Ê½Õ¾ãÄæ¼e
  32.         
  33.         .Quit
  34.     End With
  35. End Sub
½Æ»s¥N½X

TOP

¦^´_ 54# GBKEE
­ì¥»§Ú¥ç¬O¦p±z©Ò¼gªº (For ~ Next) ¤è¦¡³B­ù¡A¦ý¥¦¦b 2010 ª©¤j¬ù¦b²Ä¤G°j°é«K·|¥X²{
¿ù»~°T®§¡A©Ò¥H¥u¯à±N For ©¹¤WÂ\©ñ¡A¨C¦¸³£¦A°õ¦æ Click ªº°Ê§@¡A¤@¤Á«K¶¶¤ß¤F¡C
¬Ý¼Ë¤l´N¹³²Î­p¹Ïªíø»s¦³¨Ç»yªk³B²z¤§¾A¥Î°ÝÃD¤@¼Ë¡A¥u¯à¨Ìª©¥»¨£¾÷¦æ¨Æ¡A
ÁÂÁ±z¡I

TOP

¦^´_ 56# GBKEE
¥u¦³¤@¥y¸Ü¯à§Î®e    ----    Perfect!

TOP

¦^´_ 56# GBKEE
¦pªG§â Set ie ¥H¤Î ie.Quit §ï¦¨µùÄÀ¡A«h·|µo¥Í¦p¹Ï¤§¿ù»~¡G

TOP

¦^´_ 56# GBKEE
ªþ¤W 54# ªºµ{¦¡°õ¦æµ²ªG¡G

TOP

¦^´_ 60# GBKEE
(¦pªG§â Set ie ¥H¤Î ie.Quit §ï¦¨µùÄÀ)
ªþ¤W´ú¸Õ¥Îµ{¦¡½X¡G
  1. Sub ¹d¨Éºô2()
  2.     Dim URL As String, shts As Worksheet, ie As Object
  3.     Dim x As Variant, A As Object
  4.    
  5.     '  Set ie = CreateObject("InternetExplorer.Application")
  6.     '  ie.Navigate "about:Tabs"
  7.     '  ie.Visible = True
  8.    
  9.     Set shts = ActiveSheet    '  Sheets("¤u§@ªí2")
  10.     shts.Cells.Clear
  11.    
  12.     URL = "http://www.cnyes.com/twstock/Institutional/1101.htm"
  13.     With CreateObject("InternetExplorer.Application")
  14.         .Visible = True     '  ¬O§_Åã¥Ü IE
  15.         .Navigate URL
  16.         
  17.         Do While .ReadyState <> 4 Or .Busy: DoEvents: Loop
  18.         
  19.         For Each x In .Document.getElementsBytagname("input")
  20.             If x.Value = "¬d¸ß" Then x.Click: Exit For
  21.         Next
  22.         
  23.         Do While .ReadyState <> 4 Or .Busy: DoEvents: Loop
  24.         
  25.         Set A = .Document.getElementsBytagname("table")
  26.         For x = 1 To 6
  27.             '  With ie
  28.                 .Document.body.innerHTML = A(x).outerHTML
  29.                 .ExecWB 17, 2       '  Select All
  30.                 .ExecWB 12, 2       '  Copy selection
  31.             '  End With
  32.             
  33.             With shts
  34.                 .Range("A" & .[A65535].End(xlUp).Row + 1).Select
  35.                 .PasteSpecial Format:="HTML"
  36.             End With
  37.         Next
  38.         
  39.         shts.Cells.EntireColumn.AutoFit     '  ¦Û°Ê½Õ¾ãÄæ¼e
  40.         .Quit
  41.     End With
  42.    
  43.     '  ie.Quit
  44. End Sub
½Æ»s¥N½X

TOP

¦^´_ 60# GBKEE
§Ú­ì¥»ªº´ú¸Õµ{¦¡½X¡G
  1. Sub ¹d¨Éºô3()
  2.     Dim URL As String, shts As Worksheet
  3.     Dim x As Variant, xi As Integer
  4.    
  5.     Set shts = ActiveSheet        '  Sheets("¤u§@ªí2")
  6.     URL = "http://www.cnyes.com/twstock/Institutional/1101.htm"
  7.    
  8.     With CreateObject("InternetExplorer.Application")
  9.         .Visible = True     '  ¬O§_Åã¥Ü IE
  10.         .Navigate URL
  11.         
  12.         Do While .ReadyState <> 4 Or .Busy
  13.             DoEvents
  14.         Loop
  15.             
  16.         For Each x In .Document.getElementsBytagname("input")
  17.             If x.Value = "¬d¸ß" Then x.Click: Exit For
  18.         Next
  19.             
  20.         shts.Cells.Clear
  21.         For xi = 1 To 6
  22.             '  .document.body.innerHTML = .document.getElementsBytagname("table")(1).outerHTML
  23.             .Document.body.innerHTML = .Document.getElementsBytagname("table")(xi).outerHTML
  24.             .ExecWB 17, 2       '  Select All
  25.             .ExecWB 12, 2       '  Copy selection
  26.             
  27.             With shts
  28.                 '  .Cells.Clear
  29.                 .Range("A" & .[A65535].End(xlUp).Row + 1).Select
  30.                 .PasteSpecial Format:="HTML"
  31.                 '  .Cells.EntireColumn.AutoFit     '  ¦Û°Ê½Õ¾ãÄæ¼e
  32.             End With
  33.         Next xi
  34.         shts.Cells.EntireColumn.AutoFit     '  ¦Û°Ê½Õ¾ãÄæ¼e
  35.         
  36.         .Quit
  37.     End With
  38. End Sub
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ c_c_lai ©ó 2013-11-22 07:36 ½s¿è

¦^´_ 60# GBKEE
(¹Ï¤¤ »P54# ªºµ{¦¡½X¦³ÂI¤£¼Ë)
ªþ¤W°õ¦æ¤§µ{¦¡½X¡G
  1. Sub ¹d¨Éºô4()
  2.     Dim URL As String, shts As Worksheet
  3.     Dim x As Variant, xi As Integer, A As Object, xlHtm
  4.     Set shts = ActiveSheet '  '("¤u§@ªí2")
  5.     shts.Cells.Clear
  6.     URL = "http://www.cnyes.com/twstock/Institutional/1101.htm"
  7.     With CreateObject("InternetExplorer.Application")
  8.         .Visible = True     '  ¬O§_Åã¥Ü IE
  9.         .Navigate URL
  10.          Do While .ReadyState <> 4 Or .Busy
  11.                 DoEvents
  12.             Loop
  13.         For Each x In .Document.getElementsBytagname("input")
  14.             If x.Value = "¬d¸ß" Then x.Click: Exit For
  15.         Next
  16.         Do While .ReadyState <> 4 Or .Busy: DoEvents: Loop
  17.         xlHtm = .Document.body.innerHTML                'Àx¦s
  18.         Set A = .Document.getElementsBytagname("table")
  19.         For xi = 1 To 6
  20.             .Document.body.innerHTML = A(xi).outerHTML
  21.             .ExecWB 17, 2       '  Select All
  22.             .ExecWB 12, 2       '  Copy selection
  23.             With shts
  24.                 .Range("A" & .[A65535].End(xlUp).Row + 1).Select
  25.                 .PasteSpecial Format:="HTML"
  26.             End With
  27.             .Document.body.innerHTML = xlHtm                  'ÁÙ­ì
  28.         Next xi
  29.         shts.Cells.EntireColumn.AutoFit     '  ¦Û°Ê½Õ¾ãÄæ¼e
  30.         .Quit
  31.     End With
  32. End Sub
½Æ»s¥N½X

P.S.     ³o¬O­è¤~¤~°õ¦æ¥X¨Óªº¨MªG¡C

TOP

¦^´_ 65# GBKEE
(56#ªºµ{¦¡½X¦bªÅ¥Õºô­¶©ñ¸m "table"ªº¼gªk)
§Ú±N "ªÅ¥Õºô­¶" ÁôÂð_¨Óµøı¤W²M²n¦h¤F¡C
  1.     Set ie = CreateObject("InternetExplorer.Application")
  2.     ie.Navigate "about:Tabs"
  3.     '  ie.Visible = True
½Æ»s¥N½X
°õ¦æ¨MªG¤@¤Á OK¡C

TOP

¦^´_ 68# GBKEE
»¡ªº¤]¬O¡I
ÁÂÁ«ü¾É¡C

TOP

        ÀR«ä¦Û¦b : §Ñ¥\¤£§Ñ¹L¡A§Ñ«è¤£§Ñ®¦¡C
ªð¦^¦Cªí ¤W¤@¥DÃD