- ©«¤l
- 4
- ¥DÃD
- 2
- ºëµØ
- 0
- ¿n¤À
- 12
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows
- ³nÅ骩¥»
- 7
- ¾\ŪÅv
- 10
- µù¥U®É¶¡
- 2012-4-4
- ³Ì«áµn¿ý
- 2017-3-6
|
[µo°Ý] ½Ð°Ý ¦p¦ó¥Î vba ÂIÀ»ºô¶¬d¸ß
¥»©«³Ì«á¥Ñ GBKEE ©ó 2016-2-18 12:54 ½s¿è
ºô§}¡G http://www.twse.com.tw/ch/tradin ... T/MI_5MINS_HIST.php
<input type=button class="board" value="¬d¸ß" onclick="date_form.submit();" >
¬d¸ß¶s µLªkÂIÀ»¡A¶]¥Xªº¸ê®Æ«D³]©wªº¬d¸ß¸ê®Æ¡A
½Ð±Ð ¦p¦óקï¤U¦Cµ{¦¡½X
Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Row = 8 And .Column = 1 Then
If .Value <> 10 Then
Dim A As Object, xDate As Date, EDATE As Date
Dim myear, mmon
'myear = Year(Worksheets("¶×Á`").Cells(8, 1)) - 1911
'mmon = Month(Worksheets("¶×Á`").Cells(8, 1))
'***********´ú¸Õ¥Î
'§ì¨ì¦³¬°¤î(¥u§ì5¤Ñ)¡A5¤Ñ³£§ì¤£¨ì¤]´£¥Ü
Worksheets("¥[Åv«ü").Select
EDATE = Date
xDate = EDATE
xDate = Worksheets("¶×Á`").Cells(8, 1)
'*************
'xDate = Date '¥¿¦¡±`µ{¦¡½X
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate "http://www.twse.com.tw/ch/trading/indices/MI_5MINS_HIST/MI_5MINS_HIST.php"
Do While .Busy Or .readyState <> 4: DoEvents: Loop
Ie_Refresh:
With .Document
.ALL("myear").Value = Year(xDate) - 1911 '¤é´Á¥iקï
.ALL("mmon").Value = Format(Month(xDate), "0#")
.ALL("¬d¸ß").Click
End With
Do While .Busy Or .readyState <> 4: DoEvents: Loop
If InStr(.Document.BODY.innerText, "¬dµL¸ê®Æ") Then
If xDate >= EDATE Then '´ú¸Õ¥Î********
'If xDate + 4 >= Date Then '¥¿¦¡±`µ{¦¡½X
Debug.Print xDate 'ÅçÃҥΠ¥i§R°£
xDate = xDate - 1
GoTo Ie_Refresh
End If
.Quit
MsgBox Format(xDate, "E/MM/DD") & " ¬dµL¸ê®Æ"
Exit Sub
End If
Set A = .Document.GetElementsByTagName("table")
.Document.BODY.innerHTML = A(10).outerHTML '¨ú³Ì«áªº¤@Ó"table"
Do While .Busy Or .readyState <> 4: DoEvents: Loop
.ExecWB 17, 2 ' Select All
.ExecWB 12, 2 ' Copy selection
'.Quit 'Ãö³¬ºô¶
With ActiveSheet '¥i«ü©w¤u§@ªí
.UsedRange.Clear
.Range("A1").Select
.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NOHTMLFormatting:=True
Worksheets("¶×Á`").Select
End With
End With
Else: .Offset(0, 1) = ""
End If
End If
End With
End Sub |
|