½Ð°ª¤â¤j®v¬Û§U
n¨ú±oºô¶¤¤ªº¸ê®Æ¶·¥ý¿ï¾Ü¶µ¥Ø¡A¦ý´N¤£ª¾¦p¦ó°µ
¨Ò¦p³oÓºô¶¡A¿ï¾Ü¨ä¤¤¤@ӿﶵ¶±ªº¤º®e´N§ó·s¤F- Sub EX()
- Dim URL As String, A As Object, i As Integer, j%
- Dim AA, BB, AB$, stationName$
- URL = "http://e-service.cwb.gov.tw/HistoryDataQuery/index.jsp"
- Application.StatusBar = "¬d¸ßºô¶ ..."
- With CreateObject("InternetExplorer.Application")
- .Visible = True ' ¬O§_Åã¥Ü IE
- .Navigate URL
- Do While .ReadyState <> 4
- DoEvents
- Loop
- Application.Wait Time + #12:00:05 AM# 'µ¥Ôºô¶
- Set A = .document.All
- On Error Resume Next
- For i = 0 To A.Length - 1
- If A(i).tagname = "OPTION" Then
- If A.Item(i).Value <> "" Then
- AA = AA & "," & A(i).Value '¨ú±o´ú¯¸½s½X
- BB = BB & "," & A(i).innertext '¨ú±o¿ï¾Ü¶µ
- End If
- End If
- Next
- AA = Split(AA, ",") 'String to Array
- BB = Split(BB, ",")
-
- ' ©³¤U¬O°ÝÃDÂI¡A¦p¦óÅÜ´«ºô¶¤¤¤§ "´ú¯¸" ¿ï¶µ ¨Ï¶±§ó·s===============
- '======== ¤Î "¸ê®Æ®æ¦¡" ¿ï¶µ ¨Ó§ó·sºô¶¸ê®Æ ========================
- ' For i = 0 To UBound(BB)
- ' .document.getElementsBytagname("SELECT").Value = BB(i)
- ' .submit
- ' Next
- ' ¥H¤W¬O°ÝÃD =========================
- .ExecWB 17, 2 'Select All
- .ExecWB 12, 2 'Copy selection
-
- With ActiveSheet
- .Cells.Clear
- .Range("A1").Activate
- .PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
- False, NoHTMLFormatting:=True
- End With
-
- .Quit
- End With
- Application.StatusBar = False
- End Sub
½Æ»s¥N½X |