ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

½Ð°Ý¦p¦ó§ì¨újavascriptªº*.csvÀɮסH

¦^´_ 10# torrent
¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Sub Ex()  '¥þ³¡¸ê®Æ¶W¹L 65536µ§ 2003ª©¤£¾A¥Î
  3.     Dim Sh As Worksheet, wb As Workbook, i As Long
  4.     Set Sh = ActiveWorkbook.Sheets(1)
  5.     Sh.UsedRange = ""
  6.     i = 0
  7.     Do
  8.         Workbooks.OpenText Filename:="http://opendata.epa.gov.tw/ws/Data/EMS/?$orderby=RegistrationNo&$skip=" & i & "&$top=1000&format=csv" _
  9.             , Origin:=-535, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
  10.             xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
  11.             Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
  12.             Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _
  13.             Array(9, 1), Array(10, 1), Array(11, 1)), TrailingMinusNumbers:=True
  14.         With ActiveWorkbook.Sheets(1).UsedRange
  15.             If .Cells(1) = "" Then Exit Do
  16.             If i = 0 Then
  17.                 .Copy Sh.[a1]
  18.             Else
  19.                 .Offset(1).Copy Sh.[a1].End(xlDown).Offset(1)
  20.             End If
  21.             ActiveWorkbook.Close False
  22.         End With
  23.     i = i + 1000
  24.    Loop
  25.     ActiveWorkbook.Close False
  26. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 11# GBKEE

¨ü±Ð¤F¡A­ì¨Ó­n¥ÎWorkbooks¡C

¥t¥~¡A§Ú¦bGBKEE¤j¤jÀ°§Ú­×¥¿ªº²Ä¤G­Ócode¤¤°µ¤F¤@¨Ç­×¥¿¡A¥Øªº¬O§âAÄ檺ºÞ¨î½s¸¹¶ñº¡¡A§Ú¦b²Ä31¦C¥[¤F³o¤@¦æ¡G

.Resize(Q.ResultRange.Rows.Count, 1).Offset(2, -1).Value = Rng

¬Ý°_¨Ó°£¤F³Ì«á¤@­ÓºÞ¨î½s¸¹·|¦h¨â¦æ§À¤Ú¤§¥~¡A¦n¹³¨S¦³¨ä¥¦ªº°ÝÃD¡A¤£ª¾¹D¦U¦ì¦³¨S¦³§ó¦nªº·N¨£©Î¬Ý¥X³o¼Ë·d·|¦³bug¡H

ÁÂÁÂ

  1. Sub punish()
  2.     Dim Sh As Worksheet, Rng As Range, Q As Variant
  3.     Application.ScreenUpdating = False
  4.     Set Rng = Sheets("Sheet1").Range("A2")  'ºÞ¨î½s¸¹
  5.     On Error GoTo ER
  6.     With Sheets("ºÞ¨î¤º®e")
  7.         Set Sh = Sheets(.Name)
  8.         .UsedRange = ""
  9.     End With
  10.     On Error Resume Next
  11.     With Sh.QueryTables.Add("URL;http://prtr.epa.gov.tw/resultEMS.aspx?emsno=" & Rng & "&tab=Panel5", Sh.[AA1])
  12.         .WebSelectionType = xlSpecifiedTables
  13.         .WebFormatting = xlWebFormattingNone
  14.         .WebTables = """GridView5"""
  15.         .WebPreFormattedTextToColumns = True
  16.         .WebConsecutiveDelimitersAsOne = True
  17.         .WebSingleBlockTextImport = False
  18.         .WebDisableDateRecognition = False
  19.         .WebDisableRedirections = False
  20.         .Refresh BackgroundQuery:=False
  21.     End With
  22.     Set Q = Sh.QueryTables(1)
  23.     Do While Rng <> ""
  24.         If Err = 0 And Application.Count(Q.ResultRange) > 0 Then
  25.             With Sh.Cells(Sh.Rows.Count, 2).End(xlUp)
  26.                 .Offset(1, -1) = Rng
  27.                 If .Row = 1 Then
  28.                     .Offset(, -1) = "ºÞ¨î½s¸¹"
  29.                     Q.ResultRange.Copy .Cells
  30.                 Else
  31.                     .Resize(Q.ResultRange.Rows.Count, 1).Offset(2, -1).Value = Rng
  32.                     Q.ResultRange.Rows("2:" & Q.ResultRange.Rows.Count).Copy .Offset(1)
  33.                     
  34.                 End If
  35.             End With
  36.         End If
  37.         Err.Clear
  38.         Set Rng = Rng.Offset(1)
  39.         Q.Connection = "URL;http://prtr.epa.gov.tw/resultEMS.aspx?emsno=" & Rng & "&tab=Panel5"
  40.         Q.Refresh BackgroundQuery:=False
  41.     Loop
  42.     Q.ResultRange = ""
  43.     With Sh
  44.         .Columns.AutoFit
  45.         For Each Q In .Names
  46.            Q.Delete
  47.         Next
  48.         For Each Q In .QueryTables
  49.            Q.Delete
  50.         Next
  51.     End With
  52.    Application.ScreenUpdating = True
  53.    Exit Sub
  54. ER:
  55.     If Err.Number = 9 Then
  56.         Sheets.Add.Name = "ºÞ¨î¤º®e"
  57.         Resume
  58.     End If
  59. End Sub
½Æ»s¥N½X

TOP

¦^´_ 12# torrent
  1.            '.Resize(Q.ResultRange.Rows.Count, 1).Offset(2, -1).Value = Rng
  2.                     .Resize(Q.ResultRange.Rows.Count - 1, 1).Offset(1, -1).Value = Rng
  3.                     'Q.ResultRange.Rows.Count - 1 ->¤£¥]§tªíÀYªº¦C¼Æ
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 13# GBKEE

¦hÁ¡A³o¼Ë¶]¥X¨Óªºµ²ªG¨S¦³°ÝÃD¤F¡C

TOP

        ÀR«ä¦Û¦b : °µ¦n¨Æ¤£¯à¤Ö§Ú¤@¤H¡A°µÃa¨Æ¤£¯à¦h§Ú¤@¤H¡C
ªð¦^¦Cªí ¤W¤@¥DÃD