- ©«¤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 ©ó 2014-4-30 10:30 ½s¿è
¦^´_ 42# smart3135
WEB ¬d¸ß½Ð ª©¤W¦³³\¦h°Q½× ¥i·j´M http://www.twse.com.tw/ch/trading/exchange/FMNPTK/FMNPTKMAIN.php ³o¦r¦ê
¤W¥«»P ¤WÂd ºô¶ªº«Ø¸m¤£¦P- Option Explicit
- Dim IE As Object
- Sub IE_Application()
- Set IE = CreateObject("InternetExplorer.Application")
- With IE
- .Navigate "http://www.twse.com.tw/ch/trading/exchange/FMNPTK/FMNPTKMAIN.php"
- .Visible = True 'Åã¥Üie
- Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
- End With
- End Sub
- Sub ¤W¥«¦~¦¨¥æ¸ê°T()
- Dim E As Range, xPath As String, xFile As String, A As Object, fs As Object, F As Object, IE_URL As String
- Dim i As Integer, ii As Integer, t As Date, AR(), Rng As Range, r, C, S
- Set fs = CreateObject("Scripting.FileSystemObject")
- IE_URL = "http://www.twse.com.tw/ch/trading/exchange/FMNPTK/FMNPTKMAIN.php"
- t = Time
- Application.DisplayStatusBar = True
- Set Rng = ThisWorkbook.Sheets(3).Range("A:A")
- If Application.Count(Rng) = 0 Then MsgBox "¨S¦³ªÑ²¼¥N¸¹": Exit Sub
- Set Rng = Rng.SpecialCells(xlCellTypeConstants)
- '§A¤w±N¤W¥«ªºªÑ²¼¥N¸¹,¦bSheets(3).Range("A1")©¹¤UKey¤W,°j°é¨Ì³o¸ÌªºªÑ²¼¥N¸¹¶×¤J
- xPath = "D:\°]³ø¸ê®Æ"
- IE_Application '
- Application.StatusBar = " "
- Sheets(1).Activate
- For Each E In Rng
- With IE
- Do While .Busy Or .ReadyState <> 4: Loop
- Set A = .Document.getelementbyid("STK_NO")
- A.Value = E
- .Document.getelementSbyNAME("login_btn")(0).Click '«ö¤U¬d¸ß
- Do While .Busy Or .ReadyState <> 4: Loop
- Set A = .Document.getelementsbytagname("TABLE")
- xFile = xPath & "\" & E & "\HPM.txt"
- MkDir_Sub xFile
- With Sheets(1)
- .Cells.Clear
- For i = 1 To A(7).Rows.Length - 1
- For C = 0 To A(7).Rows(i).Cells.Length - 1
- .Cells(i, C + 1) = A(7).Rows(i).Cells(C).innertext
- Next
- Next
- .UsedRange.Sort Key1:=.Range("A2"), Order1:=xlDescending, Header:=True '±Æ§Ç:xlDescending ( ¥Ñ¤j¦Ü¤p )
- Maketxt xFile, .UsedRange
- End With
- ii = ii + 1
- End With
- Application.StatusBar = Application.Text(Time - t, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤W¥«¦~¦¨¥æ " & ii & " ¤å¦rÀÉ"
- Next
- IE.Quit
- Application.StatusBar = Application.Text(Time - t, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤W¥«¦~¦¨¥æ " & ii & " ¤å¦rÀÉ, Ū¨ú§¹²¦ !! "
- MsgBox "¶×¤J ¤å¦rÀÉ" & ii & " ¶O®É " & Application.Text(Time - t, ["MM¤ÀSS¬í"])
- ThisWorkbook.Save
- End Sub
- Sub Maketxt(xF As String, Q As Range) '*** Q As Range ****
- Dim fs As Object, E As Range, C As Variant
- Set fs = CreateObject("Scripting.FileSystemObject")
- Set fs = fs.CreateTextFile(xF, True) '³Ð¨£¤@ÓÀÉ®×,¦pÀɮצs¦b¥iÂл\±¼
- For Each E In Q.Rows 'קï³o Q.ResultRange.Rows
- C = Application.Transpose(Application.Transpose(E.Value))
- C = Join(C, vbTab)
- fs.WriteLine C
- Next
- fs.Close
- End Sub
- Sub MkDir_Sub(S As String)
- Dim AR, i As Integer, xPath As String
- If Dir(S) = "" Then
- AR = Split(S, "\")
- xPath = AR(0)
- For i = 1 To UBound(AR) - 1
- xPath = xPath & "\" & AR(i)
- If Dir(xPath, vbDirectory) = "" Then MkDir xPath
- Next
- End If
- End Sub
½Æ»s¥N½X |
|