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

[µo°Ý] CreateObject("InternetExplorer.Application") °õ¦æ§¹¦³®É·|µLªk¸õ¥X??

¦^´_ 18# t8899
³o¤è¦V¬O¹ïªº,¦³¶i¨B

  1. For S = 2 To 3                    '§ä¥Xºô­¶ªºtable ¤º®e¦b 0-3 ¤¤
  2.   'j=2
  3. IF S=2 Then j=?                '¼g¤U§Aªº±ø¥ó
  4. IF S=3 Then j=?
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_  t8899
¤@ª½¥X²{"ok"°T®§µøµ¡??  §A¬O¤¤¾Ç¥ÍÀ³¸Ó·|Ãö³¬³o"ok"µøµ¡.¦³°ÝÃD¸ÕµÛ¦Û¤v¸Ñ¨M,VBA¤~·|¶i¨B. ...
GBKEE µoªí©ó 2014-1-14 13:50

§Ú§ï¤F¤@¤U¡A¬O§_¸ò³o¦³Ãö??(¬õ¦â³¡¥÷)
Sub timestock()
Application.ScreenUpdating = False
    Dim i As Integer, S As Integer, K As Integer, j As Integer
    Dim Element
    With CreateObject("InternetExplorer.Application")
        '.Visible = True           '¥iÅã¥Üºô­¶
       .Navigate "http://newmis.twse.com.tw/stock/group.jsp?ex=tse&ind=TIDX#STATISTICS"
        Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
        Set Element = .document.getelementsbytagname("table")
        With Sheets("SHEET5")
         '  .Cells.Clear
          .Range("A1:F17").ClearContents  
            'For s = 0 To element.Length - 1 '¤£ª¾¦¹ºô­¶ªºtable¤º®e:½Ð¥ý¦æ´ú¸Õºô­¶ªº§¹¾ãtable¤º®e
            For S = 2 To 3                    '¤w§ä¥Xºô­¶ªºtable¤º®e¦b 0-3 ¤¤
                For i = 0 To Element(S).Rows.Length - 1
                    K = K + 1
               '  For j = 0 To Element(S).Rows(i).Cells.Length - 1   '¸ê®ÆªºÄæ¦ì¦@6¦ì
                     j=2
                         .Cells(K, j + 1) = Element(S).Rows(i).Cells(j).innerText
                    Next
            '   Next
            Next
     '       .Cells.EntireColumn.AutoFit            '¦Û°Ê½Õ¾ãÄæ¼e
      '      .Cells.EntireRow.AutoFit               '¦Û°Ê½Õ¾ã¦C°ª
        End With
       .Quit
    End With
    Set Element = Nothing
  '  MsgBox "0K"
End Sub

TOP

¥»©«³Ì«á¥Ñ t8899 ©ó 2014-1-14 14:48 ½s¿è
¦^´_  t8899
¤@ª½¥X²{"ok"°T®§µøµ¡??  §A¬O¤¤¾Ç¥ÍÀ³¸Ó·|Ãö³¬³o"ok"µøµ¡.¦³°ÝÃD¸ÕµÛ¦Û¤v¸Ñ¨M,VBA¤~·|¶i¨B. ...
GBKEE µoªí©ó 2014-1-14 13:50

  '  MsgBox "0K"
¥D­n¤£¬OMsgBox ªº°ÝÃD¡A¬Oie ¸õ¤£¥X¨Ó..........
²{¦b¤S¥i¥H¸õ¥X¨Ó¤F!
ÁÂÁÂ! §Ú¦Û¤v¦bºCºC§ä..........
§Ú¤]¦³¿³½ì§â¥¦§ä¥X¨Ó!:)

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-1-14 13:57 ½s¿è

¦^´_ 15# t8899
¤@ª½¥X²{"ok"°T®§µøµ¡??  §A¬O¤¤¾Ç¥ÍÀ³¸Ó·|Ãö³¬³o"ok"µøµ¡.¦³°ÝÃD¸ÕµÛ¦Û¤v¸Ñ¨M,VBA¤~·|¶i¨B.
ªþ¤WÀɮ׬ݬÝ
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¤@ª½¥X²{"ok"°T®§µøµ¡¬O®M¤J§Úªº¥¨¶°ªº¤@¬q
For i = 1 To 10
Dim aaa As Variant
aaa = Sheets("Sheet5").Range("C3")
If IsNumeric(aaa) Then Exit For
If Not IsNumeric(aaa) Then Run "timestock"
Next

TOP

¥»©«³Ì«á¥Ñ t8899 ©ó 2014-1-14 09:00 ½s¿è
¦^´_  t8899
¦¹ºô­¶ªºµ{¦¡½X
GBKEE µoªí©ó 2014-1-13 17:40

1.¦¹ºô­¶¦³¤T­Óªí®æ¡A§Ú¥u­n
²Ä¤G­Ó©ñ¤JA1¤Î
²Ä¤T­Ó"ªÑ²¼"Äæ¦ì©ñ¤JC5
¦p¦ó­×§ï?
2.¥Ñ©ó§Ú30¬í·|°õ¦æ¤@¦¸¦¹µ{§Ç
­ÉIE §ì¶}¶}ÃöÃö¡A¦ü¥G¸ûºC...¥Î¤W¼Óªºµ{§Ç¦³®ÉÁÙ¬O·|¥d¦íµLªkÃö³¬?(¤@ª½¥X²{"ok"°T®§µøµ¡")
¬O§_¦³¨ä¥L¼gªk??

TOP

¦^´_ 2# t8899
¦¹ºô­¶ªºµ{¦¡½X
  1. Option Explicit
  2. Sub timestock()
  3. Application.ScreenUpdating = False
  4.     Dim i As Integer, S As Integer, K As Integer, j As Integer
  5.     Dim Element
  6.     With CreateObject("InternetExplorer.Application")
  7.         '.Visible = True           '¥iÅã¥Üºô­¶
  8.        .Navigate "http://newmis.twse.com.tw/stock/group.jsp?ex=tse&ind=TIDX#STATISTICS"
  9.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  10.         Set Element = .document.getelementsbytagname("table")
  11.         With Sheets("SHEET5")
  12.            .Cells.Clear
  13.             'For s = 0 To element.Length - 1 '¤£ª¾¦¹ºô­¶ªºtable¤º®e:½Ð¥ý¦æ´ú¸Õºô­¶ªº§¹¾ãtable¤º®e
  14.             For S = 1 To 3                    '¤w§ä¥Xºô­¶ªºtable¤º®e¦b 0-3 ¤¤
  15.                 For i = 0 To Element(S).Rows.Length - 1
  16.                     K = K + 1
  17.                  For j = 0 To Element(S).Rows(i).Cells.Length - 1   '¸ê®ÆªºÄæ¦ì¦@6¦ì
  18.                          .Cells(K, j + 1) = Element(S).Rows(i).Cells(j).innerText
  19.                     Next
  20.                Next
  21.             Next
  22.      '       .Cells.EntireColumn.AutoFit            '¦Û°Ê½Õ¾ãÄæ¼e
  23.       '      .Cells.EntireRow.AutoFit               '¦Û°Ê½Õ¾ã¦C°ª
  24.         End With
  25.        .Quit
  26.     End With
  27.     Set Element = Nothing
  28.     MsgBox "0K"
  29. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 2# t8899
On Error Resume Next ªº¥Øªº??
«D¥²­n§O³o¼Ë¨Ï¥Î

TOP

¥»©«³Ì«á¥Ñ t8899 ©ó 2014-1-13 15:40 ½s¿è

¦³®É¥i¥H¸õ¥X??¦³®É¤SµLªk¸õ¥X??¯u©_©Ç.......
¥J²ÓÆ[¹î¡A²Ä¤@¦¸°õ¦æ¬°¨â­Óieplorer.exe ¦b°õ¦æ ??¡A±µ¤U¨Ó´N¤@¦¸¤@­Ó........
§Ú§â   .Visible = True  '==> enable
´Ý¯d¬O¤@­ÓªÅ¥Õªººô­¶

TOP

¦^´_ 8# t8899
  1. Option Explicit
  2. Sub ¶°¤¤¥«³õ¤j½L¸ê°T()
  3.     Dim x, ie As Object, Sh As Worksheet
  4.     Set ie = CreateObject("InternetExplorer.Application")
  5.    ' ie.Visible = True          '¬O§_Åã¥Ü IE
  6.     ie.Navigate "about:Tabs"    'ªÅ¥Õªººô­¶
  7.     Set Sh = ActiveSheet        '³]©w¤u§@ªí
  8.     Sh.Cells.Clear
  9.     Application.ScreenUpdating = False
  10.     With CreateObject("InternetExplorer.Application")
  11.     '    .Visible = True        '¬O§_Åã¥Ü IE
  12.         .Navigate "http://newmis.twse.com.tw/stock/group.jsp?ex=tse&ind=TIDX#STATISTICS"
  13.         Do While .readyState <> 4
  14.             DoEvents
  15.         Loop
  16.         For Each x In .document.getElementsByTagName("table")
  17.             If x.ID <> "logo" Then
  18.                 With ie
  19.                     .document.body.innerHTML = x.outerHTML
  20.                     Do While .readyState <> 4 Or .busy
  21.                         DoEvents
  22.                     Loop
  23.                     .execwb 17, 2       '  ºô­¶¤å¦r Select All
  24.                     .execwb 12, 2       '  ºô­¶¤å¦r Copy
  25.                     With Sh
  26.                         If .UsedRange.Rows.Count = 1 Then
  27.                             .Range("A1").Select
  28.                         Else
  29.                             .Range("A" & .UsedRange.Rows.Count + 1).Select
  30.                         End If
  31.                         .PasteSpecial Format:="HTML"
  32.                     End With
  33.                 End With
  34.             End If
  35.         Next
  36.         .Quit
  37.     End With
  38.     ie.Quit
  39.     With Sh
  40.         .Columns.WrapText = False
  41.         .Columns.AutoFit
  42.         .[a1].Select
  43.     End With
  44.     Application.ScreenUpdating = True
  45. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¬°¦Û¤v§äÂǤfªº¤H¥Ã»·¤£·|¶i¨B¡C
ªð¦^¦Cªí ¤W¤@¥DÃD