- ©«¤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
|
¦^´_ 55# smart3135
¥[¤Fa=Q.Cells(1)¦³¤°»ò¤£¦P©O?ÁöµM°õ¦æ®É¤£·|¥X¿ù¡A¤£¹Lµ²ªGÁÙ¬O¨SÅÜ¡A
¥[¤Fa=Q.Cells(1),¥u¬O¬°¤FÅã¥Ü©ó¹Ï¥Ü:°Ï°ìÅܼƵøµ¡¤¤ªº¤£¥i¨£¦r¤¸- Sub ¤W¥«¤ë¦¨¥æ¸ê°T()
- Dim Rng As Range, Rng1 As Range, E As Range, X As Range, T As Date, xPath As String, xFile As String
- Dim Ea As Variant, ar(), ii As Integer
- T = Time
- Application.DisplayStatusBar = True
- '½Ð±N¤WÂdªºªÑ²¼¥N¸¹,¦b Sheets(3).Range("A1")©¹¤UKey¤W,°j°é¨Ì³o¸ÌªºªÑ²¼¥N¸¹¶×¤J
- Set Rng = ThisWorkbook.Sheets(3).Range("A:A")
- Set Rng1 = ThisWorkbook.Sheets(3).Range("b:b")
- If Application.Count(Rng) = 0 Then MsgBox "¨S¦³ªÑ²¼¥N¸¹": Exit Sub
- If Application.Count(Rng1) = 0 Then MsgBox "¨S¦³ªÑ²¼¥N¸¹": Exit Sub
- Set Rng = Rng.SpecialCells(xlCellTypeConstants)
- Set Rng1 = Rng1.SpecialCells(xlCellTypeConstants)
- xPath = "D:\°]³ø¸ê®Æ"
- IE_Application '
- Application.StatusBar = " "
- For Each E In Rng
- With Sheets(1)
- .Activate
- .Cells.Clear '¤U¸ü¸ê®Æ¸m©ó¦¹¤u§@ªí,ÅÜ´«ªÑ²¼®É:²MªÅ
- End With
- For Each X In Rng1
- With IE
- .Document.getElementsByTagName("select")("myear").Value = X
- With .Document.getelementbyid("STK_NO")
- .Value = E
- .Document.getelementSbyNAME("login_btn")(0).Click '«ö¤U¬d¸ß
- End With
- Do While .Busy Or .readyState <> 4: Loop
- If .Document.getElementsByTagName("TABLE")(7).Rows.Length > 1 Then
- Ep .Document.getElementsByTagName("TABLE")(7).outerHTML
- Else
- GoTo Nn
- End If
- End With
- Next X
- Nn:
- xFile = xPath & "\" & E & "\HPM.txt"
- MkDir_Sub xFile
- Maketxt xFile, Sheets(1).Range("A1").CurrentRegion, E.Value
- ii = ii + 1
- Application.StatusBar = Application.Text(Time - T, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤WÂd¤ë¦¨¥æ " & ii & " ¤å¦rÀÉ"
- Next E
- IE.Quit
- Application.StatusBar = Application.Text(Time - T, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤WÂd¤ë¦¨¥æ " & ii & " ¤å¦rÀÉ, Ū¨ú§¹²¦ !! "
- MsgBox "¶×¤J ¤å¦rÀÉ" & ii & " ¶O®É " & Application.Text(Time - T, ["MM¤ÀSS¬í"])
- ' ThisWorkbook.Save
- End Sub
½Æ»s¥N½X- Option Explicit
- Dim IE As Object
- Sub IE_Application()
- If Not IE Is Nothing Then IE.Quit '·í¬d¨ì¤WÂdªº¦~¥÷´N·|¥X²{¬dµL,¦¹IEµLªk¦A«×¬d¸ß,Ãö³¬¥¦
- Set IE = CreateObject("InternetExplorer.Application")
- With IE
- .Navigate "http://www.gretai.org.tw/ch/stock/statistics/monthly/st44.php"
- .Visible = True '¤£Åã¥Üie
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- End With
- End Sub
- Sub ¤WÂd¤ë¦¨¥æ¸ê°T()
- Dim Rng As Range, Rng1 As Range, E As Range, X As Range, T As Date, xPath As String, xFile As String
- Dim Ea As Variant, AR(), ii As Integer, Msg As Boolean
- T = Time
- Application.DisplayStatusBar = True
- '½Ð±N¤WÂdªºªÑ²¼¥N¸¹,¦b Sheets(3).Range("A1")©¹¤UKey¤W,°j°é¨Ì³o¸ÌªºªÑ²¼¥N¸¹¶×¤J
- Set Rng = ThisWorkbook.Sheets(3).Range("A:A")
- Set Rng1 = ThisWorkbook.Sheets(3).Range("b:b")
- If Application.Count(Rng) = 0 Then MsgBox "¨S¦³ªÑ²¼¥N¸¹": Exit Sub
- If Application.Count(Rng1) = 0 Then MsgBox "¨S¦³ªÑ²¼¥N¸¹": Exit Sub
- Set Rng = Rng.SpecialCells(xlCellTypeConstants)
- Set Rng1 = Rng1.SpecialCells(xlCellTypeConstants)
- xPath = "D:\°]³ø¸ê®Æ"
- Application.StatusBar = " "
- For Each E In Rng
- If Msg = False Then IE_Application '·í¬d¨ì¤WÂdªº¦~¥÷´N·|¥X²{¬dµL,«¶}IE
- Sheets(1).UsedRange.Clear '¤U¸ü¸ê®Æ¸m©ó¦¹¤u§@ªí,ÅÜ´«ªÑ²¼®É:²MªÅ
- For Each X In Rng1
- With IE
- .document.getElementsByTagName("select")("yy").Value = X
- Do While .Busy Or .readyState <> 4: Loop
- With .document.getelementbyid("input_stock_code")
- .Value = E
- .ParentNode.submit
- End With
- Do While .Busy Or .readyState <> 4: Loop
- If InStr(.document.getElementsByTagName("TABLE")(0).innerHTML, "¬dµL¸Óµ§¸ê®Æ") = 0 Then
- Msg = True
- If Application.Count(Sheets(1).UsedRange) = 0 Then '¦¹¤u§@ªí²MªÅ®É:¤U¸ü²Ä¤@¦~«×®É
- AR = Array(0, 2)
- Else
- AR = Array(2)
- End If
- For Each Ea In AR
- Ep .document.getElementsByTagName("TABLE")(Ea).outerHTML
- Next
- Else
- Msg = False '¤WÂdªº¦~¥÷´N·|¥X²{¬dµL
- GoTo NN
- End If
- ii = ii + 1
- End With
- Next X
- NN:
- xFile = xPath & "\" & E & "\HPM.txt"
- MkDir_Sub xFile
- Maketxt xFile, Sheets(1).UsedRange
- Application.StatusBar = Application.Text(Time - T, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤WÂd¤ë¦¨¥æ " & ii / 3 & " ¤å¦rÀÉ"
- Next E
- IE.Quit
- Application.StatusBar = Application.Text(Time - T, ["MM¤ÀSS¬í"]) & " ¦@¶×¤J¤WÂd¤ë¦¨¥æ " & ii / 3 & " ¤å¦rÀÉ, Ū¨ú§¹²¦ !! "
- MsgBox "¶×¤J ¤å¦rÀÉ" & ii & " ¶O®É " & Application.Text(Time - T, ["MM¤ÀSS¬í"])
- End Sub
- Sub Maketxt(xF As String, Q As Range) '±N¶×¤J¸ê®Æ¦s¤J«ü©wªºtxt
- Dim fs As Object, E As Range, C As Variant
- Q.Range("C1") = ""
- Q.Range("A1") = Q.Range("B1") & " " & "¤ë¦¨¥æ¸ê®Æ"
- Q.Range("B1") = ""
- Q.Range("a4", Q.Range("a4").End(xlDown)).Replace "¦~", ""
- Q.Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
- Q.Rows(3).Delete '¤WÂd¤ë¦¨¥æ¸ê®Æ·í¤ëÁÙ¥¼µ²§ô®É´N·|¦³¸ê®Æ¤F,©Ò¥Hn±NÁÙ¨Sµ²§ôªº¤ë¥÷§R°£
- '¬OQ.Rows(3)¤£ Rows(4)
- Set fs = CreateObject("Scripting.FileSystemObject")
- Set fs = fs.CreateTextFile(xF, True) '³Ð¨£¤@ÓÀÉ®×,¦pÀɮצs¦b¥iÂл\±¼
- For Each E In Q.Rows
- C = Application.Transpose(Application.Transpose(E.Value))
- C = Join(C, vbTab)
- fs.WriteLine C
- Next
- fs.Close
- End Sub
½Æ»s¥N½X |
|