·sª©ªÑ¥«¤½¶}¸ê°TÆ[´ú¯¸ªº¸ê®Æ§ì¨ìEXECL?
- ©«¤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
        
|
¦^´_ 7# pupai
«ö¤U ¹Ï¤ùªººô§} http://mops.twse.com.tw/server-j ... N=3&REPORT_ID=C- Option Explicit
- Sub Ex()
- Dim URL As String, xCo_Id As String, xSyear As String, xSseason As String
- xCo_Id = "[" & """ªÑ²¼¥N¸¹""" & "," & """2485""" & "]" 'n¨D¿é¤Jºô¶ªº°Ñ¼Æ:ªÑ²¼¥N¸¹
- xSyear = "[" & """¦~«×""" & "," & """" & Format(Date, "e") & """" & "]" 'Format(Date, "e")->¤¤µØ¥Á°êªº¦~«×
- xSseason = "[" & """©u§O""" & "," & """" & Format(Date, "q") & """" & "]" 'Format(Date, "q")->·í¦~«×ªº©u§O
- URL = "URL;http://mops.twse.com.tw/server-java/t164sb01?step=1&CO_ID=" & xCo_Id & "&SYEAR=" & xSyear & "&SSEASON=" & xSseason & "&REPORT_ID=C"
- With ActiveSheet.QueryTables.Add(Connection:=URL, Destination:=Range("A1"))
- .AdjustColumnWidth = False '¦Û°Ê½Õ¾ãÄæ¼e
- .WebSelectionType = xlSpecifiedTables
- .WebFormatting = xlWebFormattingNone
- .WebTables = "2,3,4" '¸ê²£t¶Åªí,ºî¦X·l¯qªí,²{ª÷¬y¶qªí
- .WebPreFormattedTextToColumns = True
- .WebConsecutiveDelimitersAsOne = True
- .WebSingleBlockTextImport = False
- .WebDisableDateRecognition = False
- .WebDisableRedirections = False
- .Refresh BackgroundQuery:=False
- End With
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|
- ©«¤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
        
|
¦^´_ 14# PKKO
ºCºCªºÅé·|- Option Explicit
- Sub Ex_ºô¶¤¸¯À()
- Dim i As Integer, E As Object
- With CreateObject("InternetExplorer.Application")
- .Visible = True
- .Navigate "http://mops.twse.com.tw/mops/web/t164sb04"
-
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- Stop
- '¦b³oºô§}¿é¤J¬ÛÃö¸ê®Æ,¦AÄ~Äò°õ¦æ¤U±ªºµ{¦¡
-
- With .Document 'ºô¶ªº¤å¥ó
- '*** ³o¬qµ{¦¡½X¥i¬d¬Ý³oºô¶ªº¤¸¯À¤º®e
- On Error Resume Next
- For Each E In .all
- i = i + 1
- Cells(i, "a") = E.tagname '±±¨î¶µ¼Ð°Oªº¦WºÙ
- Cells(i, "b") = E.ID '±±¨î¶µ¼Ð°OªºID (±©¤@ªº)
- Cells(i, "c") = E.Name '±±¨î¶µ¼Ð°Oªº©R¦W
- Cells(i, "d") = E.Value '±±¨î¶µ¼Ð°OªºÈ
- Cells(i, "e") = E.innertext '±±¨î¶µ¼Ð°Oªº¤å¦r
- Cells(i, "f") = E.Type '±±¨î¶µ¼Ð°OªºÃþ«¬
- Cells(i, "g") = E.href '±±¨î¶µ¼Ð°Oªººô§}
- Next
- '****************************************
- End With
- ' .Quit 'Ãö³¬ºô¶
- End With
- '°õ¦æ«á¨ì¤u§@ªí¤W,¬d¬Ý¦b³oºô§}¿é¤J¬ÛÃö¸ê®Æªº±±¨î¶µªºÄÝ©Ê
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|
- ©«¤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
        
|
¦^´_ 25# chang0833
¤w×§ï ¸Õ¸Õ¬Ý- Option Explicit
- Sub Ex()
- Dim URL As String, xCo_Id As String, xSyear As String, X As Integer, Rng As Range
- Dim xSseason As Variant
- xCo_Id = Application.InputBox("½Ð¿é¤JªÑ²¼¥N¸¹", , 2303) '¹w³]¬° 2303
- X = Application.InputBox("½Ð¿é¤J³Ì·s¦~«×", , Year(Date) - 1911) '¤¤µØ¥Á°êªº¦~«×
-
- With ActiveSheet
- For Each xSseason In .QueryTables 'WEB¬d¸ßª«¥ó¶°¦X
- xSseason.Delete
- Next
- For Each xSseason In .Names 'Name ª«¥óªº¶°¦X
- .Names(xSseason.Name).Delete
- Next
- .UsedRange.Clear
- Set Rng = .Range("a1") '«ü©w¤u§@ªí¤W WEB¬d¸ßªº¦ì¸m
- End With
- '''''''''''''''''''
- For Each xSseason In Array(2, 3, 4, 1) '°j°éxSseason => 2, 3, 4, 1
- xSyear = "" & IIf(xSseason > 1, X - 2, X - 1)
- URL = "URL;http://mops.twse.com.tw/server-java/t164sb01?step=1&CO_ID=" & xCo_Id & "&SYEAR=" & xSyear & "&SSEASON=" & xSseason & "&REPORT_ID=C"
- With ActiveSheet.QueryTables.Add(Connection:=URL, Destination:=Rng)
- .Name = xCo_Id & "-" & xSyear & "- ²Ä " & xSseason & " ©u" 'WEB¬d¸ßªº¦WºÙ
- .AdjustColumnWidth = True '¦Û°Ê½Õ¾ãÄæ¼e
- .WebSelectionType = xlSpecifiedTables
- .WebFormatting = xlWebFormattingNone
- .WebTables = "2,3,4" '¸ê²£t¶Åªí,ºî¦X·l¯qªí,²{ª÷¬y¶qªí
- .WebPreFormattedTextToColumns = True
- .WebConsecutiveDelimitersAsOne = True
- .WebSingleBlockTextImport = False
- .WebDisableDateRecognition = False
- .WebDisableRedirections = False
- .Refresh BackgroundQuery:=False
- With .ResultRange 'WEB¬d¸ß¸ê®Æªº½d³ò
- Set Rng = .Cells(.Rows.Count + 2, 1) '¤U¤@WEB¬d¸ßªº¦ì¸m
- End With
- End With
- Next
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|
- ©«¤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
        
|
¦^´_ 27# chang0833
¸Õ¸Õ¬Ý(¥þ³¡)- Option Explicit
- Sub Ex()
- Dim URL As String, xCo_Id As String, X As Integer, Rng As Range
- Dim E As Variant, xSyear As Integer, xSseason As Integer, D_Name As String
-
- With ActiveSheet
- For Each E In .QueryTables 'WEB¬d¸ßª«¥ó¶°¦X
- E.Delete
- Next
- For Each E In .Names 'Name ª«¥óªº¶°¦X
- .Names(E.Name).Delete
- Next
- .UsedRange.Clear
- Set Rng = .Range("a1") '«ü©w¤u§@ªí¤W WEB¬d¸ßªº¦ì¸m
- End With
- xCo_Id = Application.InputBox("½Ð¿é¤JªÑ²¼¥N¸¹", , 2303) '¹w³]¬° 2303
- X = Year(Date) - 1910 '¤¤µØ¥Á°êªº¦~«×
- For xSyear = X To X - 3 Step -1 '°j°é:¦~«× '105->102
- 'For xSyear = X - 3 To X '°j°é:¦~«× '102->105
- For xSseason = 1 To 4 ' '°j°é:©u§O '1,2,3,4
- URL = "URL;http://mops.twse.com.tw/server-java/t164sb01?step=1&CO_ID=" & xCo_Id & "&SYEAR=" & xSyear & "&SSEASON=" & xSseason & "&REPORT_ID=C"
- With ActiveSheet.QueryTables.Add(Connection:=URL, Destination:=Rng)
- .Name = xCo_Id & "_" & xSyear & "_²Ä" & xSseason & "©u" 'WEB¬d¸ßªº¦WºÙ
- .AdjustColumnWidth = True '¦Û°Ê½Õ¾ãÄæ¼e
- .WebSelectionType = xlSpecifiedTables
- .WebFormatting = xlWebFormattingNone
- .WebTables = "2,3,4" '¸ê²£t¶Åªí,ºî¦X·l¯qªí,²{ª÷¬y¶qªí
- .WebPreFormattedTextToColumns = True
- .WebConsecutiveDelimitersAsOne = True
- .WebSingleBlockTextImport = False
- .WebDisableDateRecognition = False
- .WebDisableRedirections = False
- .Refresh BackgroundQuery:=False
- If .ResultRange.Rows.Count = 2 Then 'µL¸ê®Æ
- D_Name = .Name 'WEB¬d¸ßªº¦WºÙ
- .Delete '§R°£:WEB¬d¸ß
- With Rng.Parent
- For Each E In .Names
- If InStr(E.Name, D_Name) Then E.Delete '§R°£:¤u§@ªí¤Wªº¦WºÙ->WEB¬d¸ßªº¦WºÙ
- Next
- End With
- Else
- With .ResultRange 'WEB¬d¸ß¸ê®Æªº½d³ò
- Set Rng = .Cells(.Rows.Count + 2, 1) '¤U¤@WEB¬d¸ßªº¦ì¸m
- End With
- End If
- End With
- Next
- Next
- MsgBox "Ok"
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|