- Option Explicit
- Dim ie As Object '¼Ò²Õ³Ì³»ºÝ Dim ¨Ñ³o¼Ò²Õªºµ{§Ç¨Ï¥ÎªºÅܼÆ
- Sub AllFile()
- Dim i As Integer, v, Y As Integer, S As String
- Dim z As Integer
- Set ie = CreateObject("internetexplorer.application") '¨Ï¥Î¦¹¤è¦¡¥i¥H§K°£ "³]©w¤Þ¥Î¶µ¥Ø"
- With ie 'ÁY¤pIEµøµ¡
- .Visible = True
- .Width = 5
- .Height = 5
- End With
- With ¤u§@ªí1
- Dim AR
- AR = .Range("C1:J1")
- .Range("C:J") = ""
- .Range("C1:J1") = AR
- z = 0
- For i = 2 To .Range("A" & .Rows.Count).End(xlUp).Row
-
- v = .Cells(i, 1).Value
- GetDividend (v)
- .Cells(i, 3).Resize(1, 7).Value = ¤u§@ªí2.Cells(7, 1).Resize(1, 7).Value
- If ¤u§@ªí2.Cells(7, 5).Value > 0 Then
- .Cells(i, 10).Value = 1
- z = z + 1
- Else
- .Cells(i, 10).Value = 0
- End If
- If ¤u§@ªí2.Cells(7, 5).Value > 0 And ¤u§@ªí2.Cells(8, 5).Value > 0 And ¤u§@ªí2.Cells(9, 5).Value > 0 Then 'K(À禬³s3Ӥ륿¦¨ªø)
- .Cells(i, 11).Value = 1
- Else
- .Cells(i, 11).Value = 0
- End If
- Next
- ' MsgBox "¦@¦³" & z & "®a¥¿¦¨ªø"
- .Cells(1, 10).Value = "¥h¦~¦P´Á¦~¼W²v" & Split(Date, "/")(1) - 1 & "¤ë¥÷" & .Range("A" & .Rows.Count).End(xlUp).Row & "®a¦@¦³" & z & "®a¥¿¦¨ªø"
-
- End With
- With ie 'IEµøµ¡³Ì¤j¤Æ
- Application.WindowState = xlMaximized
- .Height = Application.Height
- .Width = Application.Width
- .Quit
- End With
- End Sub
- Public Function MyFile(v As Integer, i As Integer)
- ' Dim i As Integer, v, Y As Integer, S As String
- Set ie = CreateObject("internetexplorer.application") '¨Ï¥Î¦¹¤è¦¡¥i¥H§K°£ "³]©w¤Þ¥Î¶µ¥Ø"
- With ie 'ÁY¤pIEµøµ¡
- .Visible = True
- .Width = 5
- .Height = 5
- End With
- With ¤u§@ªí1
- .Range("C" & v & ":J" & v) = ""
- ' .Range("E2").CurrentRegion = "" '²M°£¤u§@ªí1,¦~«×½d³ò
- v = .Cells(i, 1).Value
- GetDividend (v)
- .Cells(i, 3).Resize(1, 7).Value = ¤u§@ªí2.Cells(7, 1).Resize(1, 7).Value
- If ¤u§@ªí2.Cells(7, 5).Value > 0 Then
- .Cells(i, 10).Value = 1
- ' z = z + 1
- Else
- .Cells(i, 10).Value = 0
- End If
- If ¤u§@ªí2.Cells(7, 5).Value > 0 And ¤u§@ªí2.Cells(8, 5).Value > 0 And ¤u§@ªí2.Cells(9, 5).Value > 0 Then 'k (À禬³s3Ӥ륿¦¨ªø)
- .Cells(i, 11).Value = 1
- Else
- .Cells(i, 11).Value = 0
- End If
-
- End With
- With ie 'IEµøµ¡³Ì¤j¤Æ¡B
- Application.WindowState = xlMaximized
- .Height = Application.Height
- .Width = Application.Width
- .Quit
- End With
- End Function
- Private Sub GetDividend(ByVal ss As String) '¨úªÑ§Qºô¶
- Dim rr As String, T As Date, i, ii, k, j, S As Object
- 'On Error Resume Next 'µ{¦¡ªº°õ¦æ¨S¦³¹w´Áªº¿ù»~,¦¹¦æ¥i¤£¥Î.
- T = Time
- ' rr = "http://dj.mybank.com.tw/z/zc/zch/zch_" & ss & ".asp.htm"
- 'rr = "http://www.emega.com.tw/z/zc/zch/zch_" & ss & ".ASP.HTM"
- rr = "http://pscnetinvest.moneydj.com.tw/z/zc/zch/zch_" & ss & ".djhtm"
- With ie
- .Navigate rr
- Do While .readyState <> 4 'µ¥«Ýºô¶¤U¸ü§¹²¦
- DoEvents
- If Time >= T + #12:00:03 AM# Then 'µ¥«Ý3¬í
- DoEvents
- Application.SendKeys "~" 'ªÑ²¼¥N¸¹¿ù»~,ºô¶·|¦³°T®§,¶·«ö½T©w,¤~¥iÄ~Äò¤U±ªÑ²¼¥N¸¹
-
- Exit Do
- End If
- Loop
- ''***¤£¬Oµ¥«Ý8¬í 3¬í¤Ó¤Ö·|»~¿ù§ï8§® ***
- Do
- Set S = .Document.getElementsByTagName("table")(2) ' ·sªº table 4
- Loop Until Not S Is Nothing
- '*** ³Ó¤@ ¨S®»¨ì ????
- '*** ¦]µ{¦¡¹B¦æ¤Ó§Ö , S Is Nothing, S ©|¥¼«ü©w¬°.Document.getElementsByTagName("table")(4)
- '*** µ{¦¡¤w¸g°õ¦æ¤U¤@¦æ, With ¤u§@ªí2 ªºµ{¦¡½X
- With ¤u§@ªí2
- .UsedRange.Clear
- For i = 0 To S.Rows.Length - 1 '¼g¤J¸ê®Æ
- k = k + 1
- '¥Î On Error Resume Next ¨Ïµ{¦¡Ä~Äò°õ¦æ
- For ii = 0 To S.Rows(i).Cells.Length - 1 ' S.Rows(i).Cells.Length - 1 ¤~¬O¥¿½T
- .Cells(k, ii + 1) = S.Rows(i).Cells(ii).innerText
- DoEvents
- Next
- Next
- End With
- End With
- End Sub
½Æ»s¥N½X |