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

¤U¸ü´Á³f¸ê®Æ¦Ü¤u§@ªí QueryTable¥X¿ù

¤U¸ü´Á³f¸ê®Æ¦Ü¤u§@ªí QueryTable¥X¿ù

«e½ú¦n µ{¦¡¦p¤U¡G

Option Explicit

Sub text()
  Dim myIE As InternetExplorer
  Dim myItem
  Dim QryTbl As QueryTable
  Dim myItems
  Dim WebAddress As String
  Dim mydate As Date
  Set myIE = New InternetExplorer
  With myIE
    .Visible = True
    .Navigate "http://www.taifex.com.tw/chinese/3/3_1_1.asp"
    Do Until .ReadyState = READYSTATE_COMPLETE
    Loop
  End With
  With myIE.Document.myform
    .COMMODITY_IDt.Value = "TF"                 '³]©w«´¬ù
  End With
  Set myItems = myIE.Document.getElementsByTagName("Input")
  For Each myItem In myItems
    If myItem.Value = "°e¥X¬d¸ß" Then
      myItem.Click                              '«ö¤U°e¥X¬d¸ß«ö¶s

End If
  Next
  With Worksheets("Á{®É¸ê®Æ2")
    .Cells.Clear
    Set QryTbl = .QueryTables.Add("URL;" & WebAddress, .Range("A1"))
  End With
  
  QryTbl.Refresh True

End Sub
----------------------------
¿ù»~¤@ª½¥d¦b³o¦C
  QryTbl.Refresh True
·Q½Ð±Ð¦³¤°»ò¤è¦¡¯à¸Ñ¨M¦¹°ÝÃD ..
·PÁ¦^ÂÐ:)
:)

¥»©«³Ì«á¥Ñ GBKEE ©ó 2015-6-2 17:11 ½s¿è

¦^´_ 1# cat9350621
WebAddress ¨Sµ¹
WebAddress = "http://www.taifex.com.tw/chinese/3/3_1_1.asp"  ´N¨S¦³¿ù»~
¦ý¤£¶Ç¦^«ü©wªº«´¬ù

¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Sub text()
  3.   Dim myItems As Object, myItem As Object
  4.   With New InternetExplorer
  5.     .Visible = True
  6.     .Navigate "http://www.taifex.com.tw/chinese/3/3_1_1.asp"
  7.     Do Until .readyState = READYSTATE_COMPLETE:     Loop
  8.     With .Document.myform
  9.         .COMMODITY_IDt.Value = "T5F"                 '³]©w«´¬ù
  10.     End With
  11.     Set myItems = .Document.getElementsByTagName("Input")
  12.     For Each myItem In myItems
  13.         If myItem.Value = "°e¥X¬d¸ß" Then
  14.             myItem.Click                              '«ö¤U°e¥X¬d¸ß«ö¶s
  15.         End If
  16.     Next
  17.     Do Until .readyState = READYSTATE_COMPLETE: DoEvents: Loop
  18.     Application.Wait Now + #12:00:01 AM#
  19.    
  20.     Set myItems = .Document.getElementsByTagName("table")
  21.     .Document.body.innerHTML = myItems(2).outerHTML
  22.         .ExecWB 17, 2       '  Select All
  23.         .ExecWB 12, 2       '  Copy selection
  24.         .Quit
  25.     End With
  26.     With Worksheets("Á{®É¸ê®Æ2")
  27.         .Cells.Clear
  28.         .Range("A1").Select
  29.         .PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
  30.     End With
  31. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 2# GBKEE
GBKEE ª©¤j¡A³\¤[¥¼¤©½Ð±Ð¡C
·í§Ú¨Ï¥Î With New InternetExplorer
¦b°õ¦æ®É·|²£¥Í ---
" ½sĶ¿ù»~¡G¨Ï¥ÎªÌ¦Û­q«¬ºA©|¥¼©w¸q "
¬O§_§Ú¦b³]©w¤Þ¥Î¶µ¥Ø¤¤¤Ö¥[¤J¤F­þ¤@¶µ¡H

TOP

¦^´_ 3# c_c_lai

¦p¹Ï
  
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 4# GBKEE
ÁÂÁ±z¡I¤£¹L°õ¦æ°_¨Ó¦³¨Ç¿ù»~¡A¦p¹Ï¡G

TOP

¦^´_ 5# c_c_lai
2003°õ¦æ¨S¦³¿ù»~,½Ð«ü¥X¿ù»~ÂI.

¬O   With Worksheets("Á{®É¸ê®Æ2") ???
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

Do Until .readyState = READYSTATE_COMPLETE: DoEvents: Loop
    Application.Wait Now + #12:00:01 AM#                  

§â¤W­±¨º¨â¦æ§ï¦¨¤U­±³o¤@¦æ¡A¤ñ¸û¤£·|¦]©µ¿ð¿ù»~²£¥Í¿ù»~
    Do Until .readyState = 4 And Not .Busy: DoEvents: Loop

TOP

¦^´_ 6# GBKEE
¹ï¤£°_¨S¯d·N¨ì  With Worksheets("Á{®É¸ê®Æ2")  ªº°ÝÃD¡A
ÁÂÁ«ü¥¿¡C¦P®É±N¼Ó¤W©Ò­z Do Loop ­×»\«á°õ¦æ¡A
¥X²{ "¨S¦³Åv­­"¡H

TOP

¦^´_ 8# c_c_lai
«öF8 ³v¨B¤@¦æ¤@¦æ°õ¦æµ{¦¡½X¬O¨S°ÝÃDªº.¦ýF5°õ¦æµ{§Ç·|¥X²{°ÝÃDªº.
  1. Do Until .readyState = 4 And Not .Busy: DoEvents: Loop
½Æ»s¥N½X
³oµ{¦¡½XÁöµM¬Oµ¥­Ô IE.readyState ="§¹¦¨" ,IE Not .Busy  ¤£¦£¸L ,¤§«á

¦ýºô¸ô¸ê®Æªº¤U¸ü³t«×,ÁÙ¬O¤ñµ{¦¡°õ¦æªº³t«×ºC,
¾É­P myItems ÅܼƨS¦³³]©w¨ì .Document.getElementsByTagName("table")

©Ò¥H­nµ¥­Ô¤@¤U,ºô¸ô¸ê®Æ¤U¸ü½T¹ê§¹¦¨
  1. Application.Wait Now + #12:00:01 AM#
  2. Set myItems = .Document.getElementsByTagName("table")
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 9# GBKEE
§Ú¤w±N±zªº«ü¤Þ (do until) §ï¦^¡C¥D­n¥Øªº§Ú¥u¬O¦b
´ú¸Õ¥¦ªºÀô¹Ò°õ¦æ¤§¹Lµ{»yµ²ªG¡A®{¼W±`¨£»D§OµL¥L·N¡C
ÁÂÁ±zªº¤£§[«ü¾É¡C
ªþ¤W­è¤~¤£Â_°õ¦æ©Ò¤@ª½²£¥Íªº¤­ºØª¬ªp¡A
³Ì«á¤@¦¸¤~¨£¦¨ªG¡C
·Q¥²¬Oºô¸ôÀW¼e°õ¦æ·í®É³t²v®Ä¯q¤§Ãö«Y§a¡I

TOP

        ÀR«ä¦Û¦b : ¬°¤H³B¥@­n¤p¤ß²Ó¤ß¡A¦ý¤£­n¡u¤p¤ß²´¡v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD