- ©«¤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
|
¦^´_ 8# abba9817
¤£¤F¸Ñ¥i°Ñ¦Ò³o¸Ì
¤W¥«¤u§@ªí¼Ò²Õªºµ{¦¡½X- Public ie As Object, Msg As Boolean
- Const ¹Ï§Î = "d:\ÅçÃÒ¹Ï.jpg"
- Const ÃÒ¨é¥N¸¹ = "F2"
- Const ÅçÃÒ½X = "F4"
- Private Sub Worksheet_Change(ByVal Target As Range)
- Range(ÃÒ¨é¥N¸¹).Interior.ColorIndex = IIf(Range(ÃÒ¨é¥N¸¹).Value = "", 2, 36)
- With Target.Cells(1)
- If .Address(0, 0) = ÅçÃÒ½X Then .Interior.ColorIndex = IIf(Len(Trim(.Cells)) = 5, 36, 2)
- If .Address(0, 0) = ÅçÃÒ½X And Len(Trim(.Cells)) = 5 And Range(ÃÒ¨é¥N¸¹).Value <> "" Then
- If ie Is Nothing Then
- Target = ""
- Msg = True
- ¹Ï§Î§ó·s
- Exit Sub
- End If
- Application.EnableEvents = False
- Ū¨ú¤é³øªíºô¶
- Target = ""
- Me.Activate
- Application.EnableEvents = True
- End If
- End With
- End Sub
- Private Sub Ū¨ú¤é³øªíºô¶()
- Dim S As String
- Application.EnableEvents = True
- If ie Is Nothing Then
- ¹Ï§Î§ó·s
- MsgBox "ÅçÃҹϤw§ó·s"
- Exit Sub
- End If
- With ie
- .navigate "http://bsr.twse.com.tw/bshtm/bsMenu.aspx"
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- .Document.All("TextBox_Stkno").Value = Range(ÃÒ¨é¥N¸¹)
- .Document.All("CaptchaControl1").Value = Range(ÅçÃÒ½X)
- .Document.All("btnOK").Click
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- If InStr(.Document.body.Innertext, "¬dµL¸ê®Æ") Then
- S = Range(ÃÒ¨é¥N¸¹) & " ¬dµL¸ê®Æ"
- ElseIf InStr(.Document.body.Innertext, "ÅçÃÒ½X¿ù»~!") Then
- S = "ÅçÃÒ½X¿ù»~!"
- Else
- ¤é³øªí¤U¸ü
- ¤é³øªí_¾ã²z_¦sÀÉ
- S = "¤U¸ü " & Range(ÃÒ¨é¥N¸¹) & " CSV OK"
- With Cells(Rows.Count, 1).End(xlUp)
- If .Row < 6 Then
- Range("A6") = S
- Else
- .Cells(2) = S
- End If
- End With
- End If
- [A1] = S
- End With
- ¹Ï§Î§ó·s
- End Sub
- Private Sub ¤é³øªí¤U¸ü()
- With CreateObject("InternetExplorer.Application")
- .Visible = True
- .navigate "http://bsr.twse.com.tw/bshtm/bsContent.aspx?v=t"
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- .ExecWB 17, 2
- .ExecWB 12, 2
- .Quit
- End With
- End Sub
- Private Sub ¤é³øªí_¾ã²z_¦sÀÉ()
- Dim Rng As Range, E As Range
- With Sheet2
- .Activate
- .UsedRange.Clear
- .Range("A1").Select
- .PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
- .UsedRange.Offset(10).Columns(1).Replace "¥æ©ö¤é´Á", "=aaa", xlWhole
- With .UsedRange
- For Each E In .SpecialCells(xlCellTypeFormulas, xlErrors).Areas
- If Rng Is Nothing Then
- Set Rng = E.Offset(-1).Resize(5, 16)
- Else
- Set Rng = Union(Rng, E.Offset(-1).Resize(5, 16))
- End If
- Next
- .SpecialCells(xlCellTypeBlanks).Delete xlShiftToLeft
- End With
- Rng.Delete
- .Copy '¤u§@½Æ»s
- End With
- Application.DisplayAlerts = False
- With ActiveWorkbook
- .Sheets(1).Name = Range(ÃÒ¨é¥N¸¹)
- '*******"D:\TEST\" ¥iקï ************************
- .SaveAs "D:\TEST\" & Range(ÃÒ¨é¥N¸¹).Text & ".CSV"
- '*************************************************
- .Close True
- End With
- Application.DisplayAlerts = True
- End Sub
- Private Sub ¹Ï§Î§ó·s()
- Shell "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8" 'Clear_IE_Temp_Files
- If Not ie Is Nothing Then ie.Quit: Set ie = Nothing
- Set ie = CreateObject("InternetExplorer.Application")
- If Msg Then MsgBox "ÅçÃÒ¹Ï §ó·s§¹²¦"
- Msg = False
- With ie
- .navigate "http://bsr.twse.com.tw/bshtm/bsMenu.aspx"
- .Visible = True
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- ºô¸ô¹Ï¤ù¦sÀÉ .Document.All.TAGS("IMG")(1).href
- End With
- Sheet1.Shapes("ÅçÃÒ¹Ï").Fill.UserPicture ¹Ï§Î
- End Sub
- Private Sub ºô¸ô¹Ï¤ù¦sÀÉ(img As String)
- Dim xml As Object '¥Î¨Ó¨ú±oºô¶¸ê®Æ
- Dim stream 'As ADODB.stream '¥Î¨ÓÀx¦s¤G¶i¦ìÀÉ®×
- Set xml = CreateObject("Microsoft.XMLHTTP")
- Set stream = CreateObject("ADODB.stream")
- xml.Open "GET", img, 0
- xml.send
- With stream
- .Open
- .Type = 1
- .write xml.responseBody
- If Dir(¹Ï§Î) <> "" Then Kill ¹Ï§Î
- .SaveToFile (¹Ï§Î)
- .Close
- End With
- End Sub
½Æ»s¥N½X |
|