- ©«¤l
- 78
- ¥DÃD
- 30
- ºëµØ
- 0
- ¿n¤À
- 109
- ÂI¦W
- 0
- §@·~¨t²Î
- XP
- ³nÅ骩¥»
- XP
- ¾\ŪÅv
- 20
- µù¥U®É¶¡
- 2014-5-15
- ³Ì«áµn¿ý
- 2018-9-16
|
Sub AAA()
Sheets("¤W¥«").Select
Range("B1").Select
Sheets("¤W¥«¿Ä¸ê¾lÃB").Select
Cells.Select
Selection.ClearContents
Sheets("¤W¥«").Select
Selection.Copy
Sheets("¤W¥«¿Ä¸ê¾lÃB").Select
Range("A1").Select
ActiveSheet.Paste
Dim y, m, d, param As String ' «Å§i y, m, d, param ¬°¦r¦êÅܼÆ
y = Sheets("¤W¥«¿Ä¸ê¾lÃB").Range("B2") ' ¦è¤¸¦~
m = Format(Sheets("¤W¥«¿Ä¸ê¾lÃB").Range("B3"), "00") ' ¤ë¡A¨Ï¥ÎFormat¨ç¼Æ±j¨î¤Q¦ì¼Æ¸É0
d = Format(Sheets("¤W¥«¿Ä¸ê¾lÃB").Range("B4"), "00") ' ¤é¡A¨Ï¥ÎFormat¨ç¼Æ±j¨î¤Q¦ì¼Æ¸É0
param = (y - 1911) & "/" & m & " ' ¥Á°ê¦~/¤ë/¤é"
Application.ScreenUpdating = False '°±¤î §ó·sSheet®É µe±¡A¥[³t¹Bºâ
Application.DisplayAlerts = False '°±¤î §R°£Sheet®É ¹w³]ªºÄµ§i
Cells.Clear
With CreateObject("internetexplorer.application")
.Visible = True
.Navigate "http://www.twse.com.tw/ch/trading/exchange/MI_MARGN/MI_MARGN.php"
Do Until .ReadyState = 4
DoEvents
Loop
.Document.getElementById("date-field").Value = param '¶ñ¤J
'---------¡A¤º«Øªºfireevent ªºonchange¥¢®Ä¡A§ï¥Î½Õ¥Î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 = 1
lst.dispatchEvent evt
.Document.all("query-button").Click
Do While .ReadyState <> 4 Or .Busy: DoEvents: Loop
Application.Wait Now + TimeValue("00:00:5")
' Stop
'For Z = 0 To 10
'MsgBox .Document.getElementsByTagName("table")(Z).innerText
'Next
Set hTable = .Document.getElementsByTagName("table")(4) '²Ä4Ótable
For i = 0 To hTable.Rows.Length - 1 '«e3Ó¬O¼ÐÃD»PªÅ¥Õ¸õ¹L
For J = 0 To hTable.Rows(i).Cells.Length - 1
If J = 0 And i > 2 Then
Cells(i + 1, J + 1) = "'" & hTable.Rows(i).Cells(J).innerText
Else
Cells(i + 1, J + 1) = hTable.Rows(i).Cells(J).innerText
End If
Next
Next
.Quit
End With
Range("A3:B3").Insert Shift:=xlToRight
Range("A2:B2").Select
Selection.Cut
Range("A3").Select
ActiveSheet.Paste
Range("E2:F2").Select
Selection.Cut
Range("O3").Select
ActiveSheet.Paste
Range("A1").Select
Range("D2:h2").Insert Shift:=xlToRigh
Application.ScreenUpdating = True '°±¤î §ó·sSheet®É µe±¡A¥[³t¹Bºâ
Application.DisplayAlerts = True '°±¤î §R°£Sheet®É ¹w³]ªºÄµ§i
End Sub
¤j¤j½Ð°Ý³o¸Ó«ç»ò§ï·í¤Ñªº
·Pı§Úªº¶]«ÜºC
½ÐÀ°§Ú¦£¤@¤UÁÂÁ |
|