- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¦^´_ 1# ashin1981
¸Õ¸Õ¬Ý- Option Explicit
- Sub Ex()
- Dim xDate As String, hTable As Object, i As Integer, j As Integer
- xDate = "2016/01/14"
- With CreateObject("InternetExplorer.Application")
- .Visible = True
- .Navigate "http://www.twse.com.tw/ch/trading/exchange/MI_MARGN/MI_MARGN.php"
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- .Document.getElementById("date-field").Value = Format(xDate, "EE/MM/DD") '¶ñ¤J
- '---------¡A(IE8 ª©¥»¨Ï¥Î¤º«Øªºfireevent ªºonchange)¡A°ª©óIE8ª©¥»§ï¥Î½Õ¥Îjsªº¤èªk--------
- ' Set evt = .Document.createEvent("HTMLEvents")
- ' evt.initEvent "change", True, False
- ' Set lst = .Document.all("selectType") 'optionªºname¬OselectType¡A¦ýgetElementsByNameµLªk³B²z¡Anall¤~¦æ
- ' lst.selectedIndex = 0
- ' lst.dispatchEvent evt
- .Document.all("query-button").Click
- '*****Application.Wait Now + TimeValue("00:00:5") ****
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- Do: DoEvents: Loop Until InStr(.Document.body.outerText, Format(xDate, "EE¦~MM¤ëDD¤é") & Space(1) & "«H¥Î¥æ©ö²Îp")
- 'ºô¶¤w§ó·s¬°¬d´M¤é´Áªº¸ê®Æ
- Do
- Do
- Set hTable = .Document.getElementsByTagName("table")(3) '²Ä4Ótable
- Loop Until Not hTable Is Nothing
- Loop Until hTable.Rows.Length = 5 '¨ú±o§¹¾ãª«¥ó
- '********* ¥Î°j°é ¨ú¥N Application.Wait (µ¥Ô)********
- With ActiveSheet
- .UsedRange.Clear
- For i = 1 To hTable.Rows.Length - 1 '«e3Ó¬O¼ÐÃD»PªÅ¥Õ¸õ¹L
- 'For i = 0 To hTable.Rows.Length - 1 '¼ÐÃD¶}©l
- For j = 0 To hTable.Rows(i).Cells.Length - 1
- .Cells(i, j + 1) = hTable.Rows(i).Cells(j).innertext ''«e3Ó¬O¼ÐÃD»PªÅ¥Õ¸õ¹L
- ' .Cells(i + 1, j + 1) = hTable.Rows(i).Cells(j).innertext
- Next
- Next
- End With
- .Quit
- MsgBox "OK"
- End With
- End Sub
½Æ»s¥N½X |
|