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

Object¸ê®Æ«ç»òÂà¨ìWorksheet!

Object¸ê®Æ«ç»òÂà¨ìWorksheet!

¤p§Ì¥Î¤F¤U¦CªºVBA¥h§ìYAHOOªºªÑ¥«¸ê®Æºô­¶

------------------------------------------------------------------------
Sub Webloading()

Dim i As Long
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object

Set IE = CreateObject("InternetExplorer.Application")

IE.Visible = False

IE.Navigate "http://tw.stock.yahoo.com/"

Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop

Set objCollection = IE.document.getElementsByTagName("input")
i = 0
While i < objCollection.Length
If objCollection(i).Name = "stock_id" Then
objCollection(i).Value = "2330"
Else
If objCollection(i).Type = "submit" And _
objCollection(i).Name = "xSubmit" Then
Set objElement = objCollection(i)
End If
End If
i = i + 1
Wend

objElement.Click
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop

IE.Visible = True
Set objElement = Nothing
Set objCollection = Nothing

End Sub
-------------------------------------------------------------------------

·Q½Ð±Ð¦U¦ì°ª¤â
¦p¦ó¤~¯à§âIE§ì¨ìªººô­¶¸ê®Æ¤¤¬Y­Ótable
¹³iqy«ü©wªº¤@¼ËÂà¨ì¤u§@ªí¤¤°Ú~

¤j·PÁÂ!!!
§Ú¬Oausitn.

[ª©¥DºÞ²z¯d¨¥]
  • GBKEE(2015/11/24 07:38): ªþÀɬݬÝ,À£ÁYÀɤW¶Ç

¹Á¸Õ¨Ï¥Î§ó·sªÑ²¼¥N¸¹ªºvba¡A¦ýµo²{¤@ª½¥X²{"400"¡A¤£¾å±o¬O¬Æ»ò°ÝÃD¡K

TOP

¦^´_ 1# chlungi
¸Õ¸Õ¬Ý




  1. Sub ªÑ¥«¸ê®Æºô­¶()
  2.     Dim Rng(1) As Range, i As Integer
  3.     With ActiveSheet
  4.         Set Rng(0) = .[C1]          'ªÑ²¼¥N¸¹¿é¤J³B
  5.         Set Rng(1) = .[B4]          'ªÑ²¼¼Æ¾Ú¦s©ñ°_©lÂI
  6.     End With
  7.     With CreateObject("InternetExplorer.Application")
  8.         .Navigate ("http://tw.stock.yahoo.com/q/q?s=" & Rng(0))
  9.         Do While .Busy = True
  10.         Loop
  11.         DoEvents
  12.         For i = 0 To .Document.all.Length - 1
  13.             If .Document.all(i).tagName = "TD" And Len(.Document.all(i).innerText) > 3 Then
  14.                
  15.                 If .Document.all(i).innerText Like "****/**/**" Then Rng(0).Offset(1, -1) = .Document.all(i).innerText   '¨ú±o¸ê®Æªº¤é´Á
  16.                         
  17.                 If .Document.all(i).innerText Like Rng(0) & "*" Then
  18.                     Rng(1).Value = Mid(.Document.all(i).innerText, 1, InStr(.Document.all(i).innerText, "¥[") - 2)  '¨ú±oªÑ²¼¥N¸¹¦WºÙ
  19.                     Set Rng(1) = Rng(1).Offset(, 1)                   '³]©w¤U­Ó¦ì§}
  20.                 ElseIf Len(.Document.all(i).innerText) <= 5 Then
  21.                     Rng(1).Value = .Document.all(i).innerText          '¨ú±oªÑ²¼¼Æ¾Ú
  22.                     Set Rng(1) = Rng(1).Offset(, 1)                    '³]©w¤U­Ó¦ì§}
  23.             End If
  24.             End If
  25.         Next
  26.         .Quit
  27.     End With
  28. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¤@¥y·Å·xªº¸Ü¡A´N¹³©¹§O¤H¨­¤WÅx­»¤ô¡A¦Û¤v·|ªg¨ì¨â¤Tºw¡C
ªð¦^¦Cªí ¤W¤@¥DÃD