- ©«¤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# jasonwu0114
¦Û»s¬Ý½L
ThisWorkbook µ{¦¡½X- Option Explicit
- Dim ie() As Object
- Const Sh = "¬Ý½L" '«ü©w¤u§@ªí¦WºÙ
- Private Sub Workbook_Open()
- Dim i As Integer, T As Date
- Workbook_BeforeClose False
- With Sheets(Sh)
- Application.StatusBar = "ºô¶¤U¸ü¤¤..."
- For i = 2 To .UsedRange.Columns(1).Rows.Count 'ªÑ²¼¥N¸¹
- ReDim Preserve ie(2 To i)
- If .Cells(i, "A") <> "" And IsNumeric(.Cells(i, "A")) And Len(.Cells(i, "A")) >= 4 Then
- Set ie(i) = CreateObject("InternetExplorer.Application")
- ie(i).Navigate "http://newmis.twse.com.tw/stock/fibest.jsp?stock=" & .Cells(i, "A")
- DoEvents
- Application.StatusBar = "¤U¸ü... " & .Cells(i, "A")
- ie(i).Visible = False
- Else
- Set ie(i) = Nothing
- .UsedRange.Rows(i).Offset(, 1) = ""
- End If
- Next
- End With
- T = Time + #12:00:05 AM#
- If Time < #9:00:00 AM# Then T = #9:00:00 AM#
- Application.OnTime T, "ThisWorkbook.©Ò¦³ªÑ»ù"
- End Sub
- Private Sub §Y®ÉªÑ»ù(R As Integer)
- Dim Element As Object, C As Integer
- Application.EnableEvents = False
- With Sheets(Sh)
- If Not ie(R) Is Nothing Then
- With ie(R)
- Do While .Busy Or .ReadyState <> 4: Loop
- Set Element = .document.getElementsByTagName("TABLE")(1) '
- End With
- For C = 0 To Element.Rows(1).Cells.Length - 1
- .Cells(R, C + 2) = Element.Rows(1).Cells(C).innertext
- Next
- Else
- .UsedRange.Rows(R).Offset(, 1) = ""
- End If
- End With
- Application.EnableEvents = True
- End Sub
- Private Sub ©Ò¦³ªÑ»ù()
- Dim R As Integer
- If Time >= #1:30:00 PM# Then
- Workbook_BeforeClose False
- Application.StatusBar = " ¤w¦¬½L!!!"
- Exit Sub
- End If
- For R = 2 To UBound(ie)
- §Y®ÉªÑ»ù R
- Next
- Application.OnTime Time + #12:00:02 AM#, "ThisWorkbook.©Ò¦³ªÑ»ù"
- Application.StatusBar = Time & vbTab & "§ó·s§¹¦¨"
- End Sub
- Private Sub Workbook_BeforeClose(Cancel As Boolean)
- Dim e As Variant
- On Error Resume Next
- For Each e In ie
- e.Quit
- Set e = Nothing
- Next
- End Sub
- Private Sub Workbook_SheetChange(ByVal Wsh As Object, ByVal Target As Range)
- If Wsh.Name = Sh Then
- If Target.Column = 1 And Target.Row > 1 Then Workbook_Open
- End If
- End Sub
½Æ»s¥N½X |
|