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

[µo°Ý] ¥N½XÀ³¸Ó¦p¦ó­×¥¿, ¤~¯à±N¤é´Á¶ñ¨ìºô­¶¤¤?

[µo°Ý] ¥N½XÀ³¸Ó¦p¦ó­×¥¿, ¤~¯à±N¤é´Á¶ñ¨ìºô­¶¤¤?

¦U¦ì«e½ú­Ì¤j®a¦n,
¦]¤£¾Õ©óºô­¶¾Þ±±,¥Ø«e¹J¨ì°ÝÃD¦p¤U:
§Q¥Î©³¤Uªº¤èªkµLªk±N§Ú·Q­nªº¼Æ­È(¨Ò¦p¦~103)±a¤Jºô­¶¤¤.

¥N½XÀ³¸Ó¦p¦ó­×¥¿´N¯à§JªA³o°ÝÃD?
·PÁ¦U¦ì«e½ú­Ì«ü¾É.
  1. Sub Ex()
  2. Dim my_url, B
  3. my_url = "http://mops.twse.com.tw/server-java/t13sa150_otc?step=0"
  4. With CreateObject("InternetExplorer.Application")
  5. .Visible = True
  6. .navigate my_url
  7. Do While .Busy Or .readyState <> 4: DoEvents: Loop
  8. For Each B In .document.getElementsByTagName("SELECT")
  9.     If B.Name = "years" Then B.Value = 103
  10. Next
  11. End With
  12. End Sub
½Æ»s¥N½X

¦^´_ 1# justintoolbox
¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Sub ºô­¶_contentWindow()
  3. Dim my_url As String, xDate As String, E As Object, b As Object, i As Integer, R As Integer
  4. my_url = "http://mops.twse.com.tw/server-java/t13sa150_otc?step=0"
  5. With CreateObject("InternetExplorer.Application")
  6.    ' .Visible = True
  7.     .Navigate my_url
  8.     Do While .Busy Or .readyState <> 4: DoEvents: Loop
  9.     Set E = .Document.ALL(4).contentWindow.Document  '³oºô­¶¿é¤J¤¸¯À¦b³o¸Ì
  10.     Set b = E.getElementsByTagName("SELECT")
  11.     my_url = ""
  12.     For i = 1 To b("bcode").Length
  13.         my_url = my_url & " " & i & b("bcode")(i - 1).innerText & vbLf
  14.         'Ū¨ú¤ÀÃþ¶µ¥Øªº¤º®e
  15.     Next
  16.    
  17.     Do
  18.         i = Val(InputBox(my_url, , 1)) '¤ÀÃþ¶µ¥Øªº¿ï¾Ü
  19.         If i = 0 Then
  20.             If MsgBox("¤ÀÃþ¶µ¥Ø ¨S¦³¿ï¾Ü" & vbLf & "Â÷¶} µ{¦¡?", vbYesNo) = vbYes Then
  21.                 GoTo Exx
  22.             End If
  23.         End If
  24.     Loop Until i > 0 And i <= b("bcode").Length
  25.     Do
  26.         xDate = Application.InputBox(Date, "½Ð¿é¤J¤é´Á", Date) '¸ê®Æ¤é´Á ¿é¤J
  27.         If Not IsDate(xDate) Then
  28.             If MsgBox("¸ê®Æ¤é´Á ¿é¤J¿ù»~" & vbLf & "Â÷¶} µ{¦¡?", vbYesNo) = vbYes Then
  29.                 GoTo Exx
  30.             End If
  31.         End If
  32.     Loop Until IsDate(xDate)
  33.     xDate = CDate(xDate)                                'Âର¤é´Á«¬ºA
  34.     b("bcode").selectedIndex = i - 1                    '¤ÀÃþ¶µ¥Ø
  35.     b("years").selectedIndex = Year(Date) - Year(xDate) '¦~«×
  36.     b("months").selectedIndex = Month(xDate) - 1        '¤ë¥÷
  37.     b("days").selectedIndex = Day(xDate) - 1            '¤é´Á
  38.     For Each b In E.getElementsByTagName("INPUT")
  39.         If b.Type = "submit" Then b.Click
  40.     Next
  41.     Do While .Busy Or .readyState <> 4: DoEvents: Loop
  42.     '**** §@ªk1
  43.    ' Set E = .Document.ALL(5).contentWindow.Document  '³oºô­¶¬d¸ß¸ê®Æ¦b³o¸Ì
  44.    'Set E = E.getElementsByTagName("table")(0)
  45.     'Ep E.outerHTML               'ºô­¶¸ê®Æ¤å¦r
  46.     '******************
  47.     '**** §@ªk2
  48.     Set E = .Document.ALL(5).contentWindow.Document  '³oºô­¶¬d¸ß¸ê®Æ¦b³o¸Ì
  49.     Set E = E.getElementsByTagName("table")(0).Rows
  50.     With Sheets(2)
  51.         .UsedRange.Clear
  52.         For Each b In E
  53.             For i = 0 To b.Cells.Length - 1
  54.                 .Cells(R + 1, i + 1) = b.Cells(i).innerText
  55.             Next
  56.             R = R + 1
  57.        Next
  58.     End With
  59. Exx:
  60.     .Quit
  61. End With
  62. MsgBox "ok"
  63. End Sub
  64. Sub Ep(S As String)
  65.     With CreateObject("InternetExplorer.Application")
  66.         .Navigate "about:Tabs"
  67.      '   .Visible = True
  68.         .Document.body.innerHTML = S
  69.         .ExecWB 17, 2       '  Select All
  70.         .ExecWB 12, 2       '  Copy selection
  71.         With Sheets(1)
  72.             .UsedRange.Clear
  73.             .Range("A1").Select
  74.             .PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
  75.         End With
  76.         .Quit
  77.     End With
  78. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_  justintoolbox
¸Õ¸Õ¬Ý
GBKEE µoªí©ó 2015-9-9 10:38


«D±`·PÁÂGBKEE®¼¤OÀ°¦£!¤Ó·PÁÂ.

­è­è¥ß¨è´ú¸Õ...
¥u¬O....¥X¤F°ÝÃD¦p¤U:



§Úªº¨t²Î¬O
Win8.1 64bit
EXCEL 2010 64bit
IE11

·|¤£·|¬O64bitÃö«Y©Ò­P¡H
Àµ½ÐGBKEEª©¥D«ü¾É~·PÁ¡C

TOP

[ª©¥DºÞ²z¯d¨¥]
  • GBKEE(2015/9/10 13:59): ª©Ie8ªºVBAµ{¦¡½X,¤£¯à¦b·sª©Ie¤¤¤@¦¡¨ì©³,¯u¶Ë¸£µ¬.

¦^´_ 3# justintoolbox

GBKEE¤j,
°ÝÃD¸Ñ¨M¤F,°Ñ¦Ò¥ý«eªº¤å³¹¡]http://forum.twbts.com/viewthrea ... p;extra=&page=1¡^
ÁA¸Ñ¤@¨Ç·§©À«á
¦Û¦æ§â Set E = .Document.ALL(4).contentWindow.Document§ï¦¨ Set E = .Document.ALL(3).contentWindow.Document
´N¥i¥H¤F¡I

¤Ó·PÁ ¶W¯Åª©¥D GBKEE, ·P®¦¡I

TOP

        ÀR«ä¦Û¦b : ¦¨¥\¬OÀuÂIªºµo´§¡A¥¢±Ñ¬O¯ÊÂIªº²Ö¿n¡C
ªð¦^¦Cªí ¤W¤@¥DÃD