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

´Á³f¥æ©ö©Ò¹dÃBªÑ²¼´Á³f¸ê®Æ¾e¨ú

´Á³f¥æ©ö©Ò¹dÃBªÑ²¼´Á³f¸ê®Æ¾e¨ú

´Á³f¥æ©ö©Òºô¯¸
http://www.taifex.com.tw/chinese/3/3_3_3.asp
«´¬ù:ªÑ²¼´Á³f
¥u¯à¬Ý
EXCEL¬d¸ß¤S¦^¨ì
«´¬ù:¥x«ü´Á³f(TX)

¦³¿ìªk EXCEL VBA ¾e¨ú «´¬ù:ªÑ²¼´Á³f ¶Ü??????!!!!!
½Ð±Ð°ª¤â­Ì.......

¦^´_ 1# chwqk
  1. Option Explicit
  2. Sub Ex_¥x´Á_¦U°Ó«~¦¨¥æ¸ê°T()
  3.     Dim E As Object, i As Integer, ii As Integer, K As Integer
  4.     Dim xadte As Date
  5.     xadte = DateAdd("yyyy", -1, Date)  '¤é´Á(°_)¡G
  6.     With CreateObject("InternetExplorer.Application")
  7.         .Visible = True
  8.         .Navigate "http://www.taifex.com.tw/chinese/3/3_3_3.asp"
  9.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  10.         
  11.         '<OPTION value="TX" selected>¥xªÑ´Á³f(TX)</OPTION>
  12.         '<OPTION value="MTX" >¤p«¬¥x«ü(MTX)</OPTION>
  13.         '<OPTION value="TXO" >¥x«ü¿ï¾ÜÅv(TXO)</OPTION>
  14.         '<OPTION value="STF" >ªÑ²¼´Á³f</OPTION>
  15.         .document.ALL("commodity_idt").Value = "STF"  '«´¬ù: ªÑ²¼´Á³f
  16.         
  17.         With .document.getElementsByTAGName("INPUT")
  18.             .Item("datestart").Value = Format(xadte, "YYYY/MM/DD")
  19.             .Item("dateend").Value = Format(Date, "YYYY/MM/DD")
  20.             .Item("button3").Click
  21.         End With
  22.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  23.         Set E = .document.getElementsByTAGName("TABLE")(3)
  24.         ActiveSheet.UsedRange.Clear
  25.         For i = 0 To E.Rows.Length - 1
  26.             K = K + 1
  27.             For ii = 0 To E.Rows(i).Cells.Length - 1
  28.                 Cells(K, ii + 1) = E.Rows(i).Cells(ii).INNERTEXT
  29.             Next
  30.         Next
  31.         .Quit        'Ãö³¬ºô­¶
  32.     End With
  33. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 2# GBKEE

¤£¦n·N«ä¦APO¤@¦¸
  1. Option Explicit
  2. Sub Ex_¥x´Á_¦U°Ó«~¦¨¥æ¸ê°T()
  3.     Dim E As Object, i As Integer, ii As Integer, K As Integer
  4.     Dim xadte As Date
  5.     xadte = DateAdd("yyyy", -1, Date)  '¤é´Á(°_)¡G
  6.     With CreateObject("InternetExplorer.Application")
  7.         .Visible = True
  8.         .Navigate "http://www.taifex.com.tw/chinese/3/7_12_6.asp"
  9.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  10.         
  11.         '<OPTION value="TX" selected>¥xªÑ´Á³f(TX)</OPTION>
  12.         '<OPTION value="MTX" >¤p«¬¥x«ü(MTX)</OPTION>
  13.         '<OPTION value="TXO" >¥x«ü¿ï¾ÜÅv(TXO)</OPTION>
  14.         '<OPTION value="STF" >ªÑ²¼´Á³f</OPTION>
  15.         '.document.ALL("commodity_idt").Value = "STF"  '«´¬ù: ªÑ²¼´Á³f
  16.         
  17.         With .document.getElementsByTAGName("INPUT")
  18.             .Item("datestart").Value = Format(xadte, "YYYY/MM/DD")
  19.             .Item("dateend").Value = Format(Date, "YYYY/MM/DD")
  20.             .Item("button4").Click
  21.         End With
  22.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  23.         Set E = .document.getElementsByTAGName("TABLE")(3)
  24.         ActiveSheet.UsedRange.Clear
  25.         For i = 0 To E.Rows.Length - 1
  26.             K = K + 1
  27.             For ii = 0 To E.Rows(i).Cells.Length - 1
  28.                 Cells(K, ii + 1) = E.Rows(i).Cells(ii).INNERTEXT
  29.             Next
  30.         Next
  31.         .Quit        'Ãö³¬ºô­¶
  32.     End With
  33. End Sub
½Æ»s¥N½X

TOP

¦^´_ 3# leoncc
³oºô­¶¬O­n¤U¸üÀÉ®×
  1. Option Explicit
  2. Sub Ex_¥x´Á_¦U°Ó«~¦¨¥æ¸ê°T()
  3.     Dim xDate(1 To 2) As Date, xPath As String, wB As String
  4.     'IE ¤U¸üÀɮתº¸ê®Æ§¨
  5.     xPath = "C:\Documents and Settings\hsu\My Documents\"
  6.     '²MªÅ ¤U¸üÀɮתº¸ê®Æ§¨ ªºcsvÀÉ
  7.     If Dir(xPath & "*.csv") <> "" Then Kill xPath & "*.csv"
  8.    
  9.     xDate(1) = DateAdd("yyyy", -1, Date)        '¤é´Á(°_)¡G
  10.     xDate(2) = Date                             '¤é´Á(¨´)¡G
  11.     If Weekday(Date, vbMonday) >= 6 Then        '·í¤é«DÀç·~¤é
  12.         Do While Weekday(Date, vbMonday) >= 6
  13.             xDate(2) = xDate(2) - 1
  14.         Loop
  15.     ElseIf Time < #3:00:00 PM# Then
  16.         xDate(2) = xDate(2) - 1                 '·í¤é¤j½L¸ê®Æ©|¥¼¾ã²z§¹²¦
  17.     End If
  18.    
  19.     With CreateObject("InternetExplorer.Application")
  20.         .Visible = True
  21.         .Navigate "http://www.taifex.com.tw/chinese/3/7_12_6.asp"
  22.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  23.         
  24.         '<OPTION value="TX" selected>¥xªÑ´Á³f(TX)</OPTION>
  25.         '<OPTION value="MTX" >¤p«¬¥x«ü(MTX)</OPTION>
  26.         '<OPTION value="TXO" >¥x«ü¿ï¾ÜÅv(TXO)</OPTION>
  27.         '<OPTION value="STF" >ªÑ²¼´Á³f</OPTION>
  28.         '.document.ALL("commodity_idt").Value = "STF"  '«´¬ù: ªÑ²¼´Á³f
  29.         
  30.         With .document.getElementsByTAGName("INPUT")
  31.             .Item("datestart").Value = Format(xDate(1), "YYYY/MM/DD")
  32.             .Item("dateend").Value = Format(xDate(2), "YYYY/MM/DD")
  33.             .Item("button4").Click
  34.         End With
  35.           Application.Wait Now + #12:00:02 AM#
  36.           Application.SendKeys "%s", True
  37.           Application.Wait Now + #12:00:01 AM#  '¦pVBA°õ¦æ³t«×§Ö,¥i©µªø¬í¼Æ
  38.           Application.SendKeys "%s", True
  39.         .Quit        'Ãö³¬ºô­¶
  40.     End With
  41.      wB = Dir(xPath & "*.csv")
  42.      If wB <> "" Then Workbooks.Open (xPath & wB) '¶}±Ò¤U¸üªºÀÉ®×
  43. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 4# GBKEE



ÁÂÁÂG¤j¦^ÂСA¦ý¥i¯à­n¦A³Â·ÐG¤j¤F¡A¤p§Ì°õ¦æ«á¡AµL¥ô¦ó¿ù»~¡B¦ý¤]µL¥ô¦ó¸ê®Æ¡AÀɮפ´¬OªÅ¥Õ¡C ¤p§Ì¸Õ¹L§ó§ï¦sÀɸô®|¡A¦ý¤´¬OªÅ¥Õ¡C¤£³Ó·P¿E

TOP

¦^´_ 5# leoncc

IE8¤U¸üÀɮ׸ê®Æ§¨, ¶·¬O«e¤@¦¸¤U¸üÀɮ׸ê®Æ§¨
¦p¹Ï


IE8  ¦p¤£³o¿ï¶µ¤£¤Ä¿ï



¥iª½±µ¶}±ÒÀÉ®×(IE8 ¥H¤WªºIE ¤]¥i¥H¸Õ¬Ý¬Ý
  1. With .document.getElementsByTAGName("INPUT")
  2.             .Item("datestart").Value = Format(xDate(1), "YYYY/MM/DD")
  3.             .Item("dateend").Value = Format(xDate(2), "YYYY/MM/DD")
  4.             .Item("button4").Click
  5.         End With
  6.           Application.Wait Now + #12:00:02 AM#
  7.           Application.SendKeys "%s", True       'Àx¦s
  8.           Application.Wait Now + #12:00:02 AM#  '¦pVBA°õ¦æ³t«×§Ö,¥i©µªø¬í¼Æ
  9.           Application.SendKeys "%s", True       '¥t¦s·sÀÉ
  10.           Application.Wait Now + #12:00:02 AM#
  11.           Application.SendKeys "%O", True       ' ***¶}±ÒÀÉ®×***
  12.         .Quit        'Ãö³¬ºô­¶
½Æ»s¥N½X
³o¬qµ{¦¡½X¥i§R°£
  1.   xPath = "C:\Documents and Settings\hsu\My Documents\"
  2.    If Dir(xPath & "*.csv") <> "" Then Kill xPath & "*.csv"
  3. '*************
  4. wB = Dir(xPath & "*.csv")
  5.    If wB <> "" Then Workbooks.Open (xPath & wB) '¶}±Ò¤U¸üªºÀÉ®×
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 6# GBKEE

G¤j±z¦n

¦­¤W10:40´ú¸Õ¤F¤@¤U¡AÁÙ¬O¥X²{¤U¦C¿ù»~:



°£¤W­z¿ù»~¥~¡AÀɮרõL¥ô¦ó°Ê§@¡A¤]¨S¦³G¤j©Ò­z¤U¸üÀɮתºµøµ¡¡C
¥t¥~¸òG¤j³ø§i¡A§Úªº¬OIE11¡A­n¦A³Â·ÐG¤j¤F ¤£¦n·N«ä

­ì©l½X:
  1. Option Explicit
  2. Sub Ex_¥x´Á_¦U°Ó«~¦¨¥æ¸ê°T()
  3.     Dim xDate(1 To 2) As Date, xPath As String, wB As String
  4.     'IE ¤U¸üÀɮתº¸ê®Æ§¨
  5.    ' xPath = "C:\Documents and Settings\hsu\My Documents\"
  6.     '²MªÅ ¤U¸üÀɮתº¸ê®Æ§¨ ªºcsvÀÉ
  7.     'If Dir(xPath & "*.csv") <> "" Then Kill xPath & "*.csv"
  8.    
  9.     xDate(1) = DateAdd("yyyy", -1, Date)        '¤é´Á(°_)¡G
  10.     xDate(2) = Date                             '¤é´Á(¨´)¡G
  11.     If Weekday(Date, vbMonday) >= 6 Then        '·í¤é«DÀç·~¤é
  12.         Do While Weekday(Date, vbMonday) >= 6
  13.             xDate(2) = xDate(2) - 1
  14.         Loop
  15.     ElseIf Time < #3:00:00 PM# Then
  16.         xDate(2) = xDate(2) - 1                 '·í¤é¤j½L¸ê®Æ©|¥¼¾ã²z§¹²¦
  17.     End If
  18.    
  19.     With CreateObject("InternetExplorer.Application")
  20.         .Visible = True
  21.         .Navigate "http://www.taifex.com.tw/chinese/3/7_12_6.asp"
  22.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  23.         
  24.         '<OPTION value="TX" selected>¥xªÑ´Á³f(TX)</OPTION>
  25.         '<OPTION value="MTX" >¤p«¬¥x«ü(MTX)</OPTION>
  26.         '<OPTION value="TXO" >¥x«ü¿ï¾ÜÅv(TXO)</OPTION>
  27.         '<OPTION value="STF" >ªÑ²¼´Á³f</OPTION>
  28.         '.document.ALL("commodity_idt").Value = "STF"  '«´¬ù: ªÑ²¼´Á³f
  29.         
  30.         With .document.getElementsByTAGName("INPUT")
  31.             .Item("datestart").Value = Format(xDate(1), "YYYY/MM/DD")
  32.             .Item("dateend").Value = Format(xDate(2), "YYYY/MM/DD")
  33.             .Item("button4").Click
  34.         End With
  35.           Application.Wait Now + #12:00:02 AM#
  36.           Application.SendKeys "%s", True       'Àx¦s
  37.           Application.Wait Now + #12:00:02 AM#  '¦pVBA°õ¦æ³t«×§Ö,¥i©µªø¬í¼Æ
  38.           Application.SendKeys "%s", True       '¥t¦s·sÀÉ
  39.           Application.Wait Now + #12:00:02 AM#
  40.           Application.SendKeys "%O", True       ' ***¶}±ÒÀÉ®×***
  41.         .Quit        'Ãö³¬ºô­¶

  42.     End With
  43.     ' wB = Dir(xPath & "*.csv")
  44.      'If wB <> "" Then Workbooks.Open (xPath & wB) '¶}±Ò¤U¸üªºÀÉ®×
  45. End Sub
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2015-6-1 14:10 ½s¿è

¦^´_ 7# leoncc
¦A¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Sub Ex_¥x´Á_¦U°Ó«~¦¨¥æ¸ê°T()
  3.     Dim xDate(1 To 2) As Date, xPath As String, wB As String
  4.     xDate(1) = DateAdd("yyyy", -1, Date)        '¤é´Á(°_)¡G
  5.     xDate(2) = Date                             '¤é´Á(¨´)¡G
  6.     If Time < #3:00:00 PM# Then                  'Àç®É¶¡·~µ²§ô¤§«e«Ý¤j½L¸ê®Æ¾ã²z§¹²¦
  7.         Do While Weekday(xDate(2), vbMonday) >= 6 Or Weekday(xDate(2), vbMonday) = 1
  8.             '±Æ°£ ¶g¤»,¶g¤é,¶g¤@
  9.             xDate(2) = xDate(2) - 1   '¦V«e´î¤@¤é
  10.         Loop
  11.     ElseIf Time < #3:00:00 PM# Then     ''·í¤é¤j½L¸ê®Æ¾ã²z§¹²¦
  12.         Do While Weekday(xDate(2), vbMonday) >= 6 '±Æ°£ ¶g¤»,¶g¤é
  13.             xDate(2) = xDate(2) - 1   '¦V«e´î¤@¤é
  14.         Loop
  15.     End If
  16.     With CreateObject("InternetExplorer.Application")
  17.         .Visible = True
  18.         .Navigate "http://www.taifex.com.tw/chinese/3/7_12_6.asp"
  19.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  20.         
  21.         '<OPTION value="TX" selected>¥xªÑ´Á³f(TX)</OPTION>
  22.         '<OPTION value="MTX" >¤p«¬¥x«ü(MTX)</OPTION>
  23.         '<OPTION value="TXO" >¥x«ü¿ï¾ÜÅv(TXO)</OPTION>
  24.         '<OPTION value="STF" >ªÑ²¼´Á³f</OPTION>
  25.         '.document.ALL("commodity_idt").Value = "STF"  '«´¬ù: ªÑ²¼´Á³f
  26.         
  27.         With .Document.getElementsByTAGName("INPUT")
  28.             .Item("datestart").Value = Format(xDate(1), "YYYY/MM/DD")
  29.             .Item("dateend").Value = Format(xDate(2), "YYYY/MM/DD")
  30.             .Item("button4").Click
  31.         End With
  32.           Application.Wait Now + #12:00:02 AM#
  33.           Application.SendKeys "%s", True       'Àx¦s
  34.           Application.Wait Now + #12:00:02 AM#  '¦pVBA°õ¦æ³t«×§Ö,¥i©µªø¬í¼Æ
  35.           Application.SendKeys "%s", True       '¥t¦s·sÀÉ
  36.           Application.Wait Now + #12:00:02 AM#
  37.           Application.SendKeys "%O", True       ' ***¶}±ÒÀÉ®×***
  38.         .Quit        'Ãö³¬ºô­¶
  39.     End With
  40.   
  41. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¡i°µ¤Hªº¶}©l¡j¨C¤@¤Ñ³£¬O¬G¤Hªº¶}©l¡A¨C¤@­Ó®É¨è³£¬O¦Û¤vªºÄµ±§¡C
ªð¦^¦Cªí ¤W¤@¥DÃD