- ©«¤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# flask
³ÌªñªÑ²¼¤½¶}ºô¶¸ê°Tªº¤U¸ü,³£¦³ÅçÃÒ½X¨¾¤î¦Û°Ê¤U¸ü.
¥Ñ©óÅçÃÒ½X¤£¦n¯}¸Ñ,¥i¸Õ¸Õ¥b¦Û°Ê¤U¸ü
1½Ð¦b¤u§@ªí¤W´¡¤J¤@¹Ï¤ù(©R¦W:ÅçÃÒ¹Ï)
2¹Ï¤ù¥¨¶°«ü©w¬° ,Sheet1.¹Ï§Î§ó·s,³oµ{¦¡
¬°¨ÏVBA¤JªùªÌ,¦³¹ê§@¸gÅç,¬G¶Èªþ¤Wµ{¦¡½X.
ThisWorkbook¼Ò²Õªºµ{¦¡½X- Option Explicit
- Private Sub Workbook_Open()
- Sheet1.Msg = True
- Run "Sheet1.¹Ï§Î§ó·s"
- End Sub
- Private Sub Workbook_BeforeClose(Cancel As Boolean)
- On Error Resume Next
- If Not Sheet1.IE Is Nothing Then Sheet1.IE.Quit
- End Sub
½Æ»s¥N½X Sheet1¼Ò²Õªºµ{¦¡½X- Option Explicit
- 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
- ¤é³øªí¸ü¤J
- Target = ""
- Application.EnableEvents = True
- End If
- End With
- End Sub
- Private Sub ¤é³øªí¸ü¤J()
- Dim e As Object, a As Object, K As Integer, i As Integer, ii As Integer, s As String
- If IE Is Nothing Then
- ¹Ï§Î§ó·s
- MsgBox "ÅçÃҹϤw§ó·s"
- Exit Sub
- End If
- With IE
- .Document.ALL.tags("INPUT")("stk_code").Value = Range(ÃÒ¨é¥N¸¹)
- .Document.ALL.tags("INPUT")("auth_num").Value = Trim(Range(ÅçÃÒ½X))
- Set a = .Document.ALL.tags("BUTTON")
- For Each e In a
- If Trim(e.innertext) = "¬d¸ß" And e.ID = "" Then
- e.Click
- Exit For
- End If
- Next
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- K = 6
- UsedRange.Offset(6).Clear
- If .Document.body.innertext Like "***¸ÓªÑ²¼¸Ó¤éµL¥æ©ö¸ê°T***" Then s = "***¸ÓªÑ²¼¸Ó¤éµL¥æ©ö¸ê°T***"
- If .Document.body.innertext Like "***ÅçÃÒ½X¿ù»~¡A½Ð«·s¬d¸ß¡C***" Then s = "***ÅçÃÒ½X¿ù»~¡A½Ð«·s¬d¸ß¡C*** "
- If s <> "" Then
- Range("a" & K + 1) = s
- MsgBox s
- GoTo NN
- End If
- Set a = .Document.ALL.tags("table")(0)
- For i = 0 To a.Rows.Length - 1
- K = K + 1
- For ii = 0 To a.Rows(i).Cells.Length - 1
- Cells(K, ii + 1) = a.Rows(i).Cells(ii).innertext
- Next
- Next
- Set a = .Document.ALL.tags("table")(2)
- K = K + 1
- For i = 0 To a.Rows.Length - 1
- K = K + 1
- For ii = 0 To a.Rows(i).Cells.Length - 1
- Cells(K, ii + 1) = a.Rows(i).Cells(ii).innertext
- Next
- Next
- Set a = .Document.ALL.tags("table")(3)
- For i = 1 To a.Rows.Length - 1
- K = K + 1
- For ii = 0 To a.Rows(i).Cells.Length - 1
- Cells(K, ii + 1) = a.Rows(i).Cells(ii).innertext
- Next
- Next
- MsgBox Range("d7") & " ¤é³øªí¸ü¤J §¹²¦!!"
- NN:
- .Quit
- End With
- Set IE = Nothing
- ¹Ï§Î§ó·s
- End Sub
- Private Sub Get_Ie()
- Set IE = CreateObject("InternetExplorer.Application")
- With IE
- ' .Visible = True
- '¨é°Ó¶R½æÃÒ¨é¤é³øªí¬d¸ß¨t²Î¡]¤@¯ë¥æ©ö¡^
- .Navigate "http://www.gretai.org.tw/web/stock/aftertrading/broker_trading/brokerBS.php?l=zh-tw"
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- End With
- End Sub
- Private Sub ¹Ï§Î§ó·s()
- If IE Is Nothing Then Get_Ie
- If Msg Then MsgBox "ÅçÃÒ¹Ï §ó·s§¹²¦"
- Msg = False
- With IE
- .Refresh
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- ºô¸ô¹Ï¤ù¦sÀÉ .Document.ALL.tags("IMG")(0).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 |
|