- ©«¤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
|
¥»©«³Ì«á¥Ñ GBKEE ©ó 2018-1-30 12:47 ½s¿è
¦^´_ 6# iamaraymond
³oºô¶¥ÎQueryTable ±o¨úªº¸ê®Æ¦³®É°_©l¤é´Á·|¤£·Ç½T,¸Õ¸Õקï°_©l¤é´Á,¬Ý¬Ý¸ê®Æ¬O§_¥¿½T
¦^´_ 7# Scott090 - Option Explicit
- Sub Ex_Ie_Copy()
- Dim Code As String, Price()
- Dim date0 As Date, StartDate$, EndDate$, timer, time0 As Date, IE_StartDate As String
- Dim E As Object, IE As Object
- Code = "2330"
- time0 = Time
- Application.StatusBar = "¶}±Òºô¶...."
- '³]©w¸ê®Æ¶}©l¤Îµ²§ô¤é´Á
- StartDate = Format(DateAdd("m", -12 * 10, Date), "yyyy/mm/dd") '¨ú10¦~¸ê®Æµ§
- If StartDate < CDate("1994/09/07") Then
- MsgBox "StartDate " & StartDate & vbLf & "¤£¥i¤p©ó" & "1994/09/07"
- End
- End If
- EndDate = Format(Date, "yyyy/mm/dd")
- Set IE = CreateObject("InternetExplorer.Application")
- With IE
- .navigate "http://www.cnyes.com/twstock/ps_historyprice/" & Code & ".htm"
- Do: DoEvents: Loop While .Busy Or .readystate <> 4
- With .Document.getElementsByTagName("input")
- .Item("ctl00$ContentPlaceHolder1$startText").Value = StartDate ' ¶}©l¤é´Á input name
- .Item("ctl00$ContentPlaceHolder1$endText").Value = EndDate ' µ²§ô¤é´Á input name
- .Item("ctl00$ContentPlaceHolder1$submitBut").Click
- End With
- Do: DoEvents: Loop While .Busy Or .readystate <> 4
- On Error Resume Next
- Do
- Err.Clear
- Set E = .Document.getElementsByTagName("TABLE")(0)
- If E.INNERTEXT <> "" Then
- If Err = 0 Then
- If Abs(DateValue(E.Rows(E.Rows.Length - 1).Cells(0).INNERTEXT) - DateValue(StartDate)) <= 15 Then
- If Err = 0 Then Exit Do
- End If
- End If
- End If
- DoEvents
- Application.StatusBar = " µ¥Ô ºô¶¸ê®Æ¤¤ ... "
- Loop
- On Error GoTo 0
- CopyToClipbox E.OUTERHTML
- Application.StatusBar = StartDate & " - " & EndDate & " ¸ê®Æ¦@ " & E.Rows.Length - 1 & " Ū¨ú.." & Application.Text(Time - time0, ["m¤À:S¬í ok"])
- .Quit
- End With
- End Sub
- Private Sub CopyToClipbox(strText As String) '¤å¥»«þ¨©¨ì°Å¶KªO
- With CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
- .SetText strText
- .PutInClipboard
- End With
- With ActiveSheet
- .UsedRange.Clear
- .[A1].Select
- .Paste
- End With
- End Sub
½Æ»s¥N½X- Sub Ex_Ie()
- Dim Code As String, Price()
- Dim StartDate$, EndDate$, time0 As Date
- Dim E As Object
- Dim Re%, Ce%
- Code = "2330"
- time0 = Time
- ActiveSheet.Cells.Clear
- Cells(1).Activate
- Application.StatusBar = "¶}±Òºô¶...."
- '³]©w¸ê®Æ¶}©l¤Îµ²§ô¤é´Á
- StartDate = Format(DateAdd("m", -12 * 10, Date), "yyyy/mm/dd") '¨ú10¦~¸ê®Æµ§
- If StartDate < CDate("1994/09/07") Then
- MsgBox "StartDate " & StartDate & vbLf & "¤£¥i¤p©ó" & "1994/09/07"
- End
- End If
- EndDate = Format(Date, "yyyy/mm/dd")
-
- With CreateObject("InternetExplorer.Application")
- .navigate "http://www.cnyes.com/twstock/ps_historyprice/" & Code & ".htm"
- Do: DoEvents: Loop While .Busy Or .readystate <> 4
- With .Document.getElementsByTagName("input")
- .Item("ctl00$ContentPlaceHolder1$startText").Value = StartDate ' ¶}©l¤é´Á input name
- .Item("ctl00$ContentPlaceHolder1$endText").Value = EndDate ' µ²§ô¤é´Á input name
- .Item("ctl00$ContentPlaceHolder1$submitBut").Click
- End With
- Do: DoEvents: Loop While .Busy Or .readystate <> 4
- On Error Resume Next
- Do
- Err.Clear
- Set E = .Document.getElementsByTagName("TABLE")(0)
- If E.INNERTEXT <> "" Then
- If Err = 0 Then
- If Abs(DateValue(E.Rows(E.Rows.Length - 1).Cells(0).INNERTEXT) - DateValue(StartDate)) <= 15 Then
- If Err = 0 Then Exit Do
- End If
- End If
- End If
- DoEvents
- Application.StatusBar = " µ¥Ô ºô¶¸ê®Æ¤¤ ... "
- Loop
- On Error GoTo 0
- 'ReDim Price(0 To E.Rows.Length - 1, 0 To E.Rows(0).Cells.Length - 1)
- Application.StatusBar = StartDate & " - " & EndDate & " ¸ê®Æ¦@ " & E.Rows.Length - 2 & " Ū¨ú...... "
- For Re = 0 To E.Rows.Length - 1 ' 19 '¨ú19¤Ñªº¾ú¥v¬ö¿ý
- For Ce = 0 To E.Rows(Re).Cells.Length - 1
- Cells(Re + 1, Ce + 1) = E.Rows(Re).Cells(Ce).INNERTEXT '¤é´Á¡B¶}¡B°ª¡B§C¡B¦¬¡Bº¦¶^ º¦% ¦¨¥æ¶q ¦¨¥æª÷ÃB
- ' Price(Re, Ce) = E.Rows(Re).Cells(Ce).innertext '¤é´Á¡B¶}¡B°ª¡B§C¡B¦¬¡Bº¦¶^ º¦% ¦¨¥æ¶q ¦¨¥æª÷ÃB
- Next
- Next
- 'ActiveSheet.Cells(1, "A").Resize(UBound(Price), UBound(Price, 2)).Value = Price
- Application.StatusBar = StartDate & " - " & EndDate & " ¸ê®Æ¦@ " & E.Rows.Length - 2 & " Ū¨ú.." & Application.Text(Time - time0, ["m¤À:S¬í ok"])
- .Quit
- End With
- End Sub
½Æ»s¥N½X |
|