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

ª½±µ§ì°£®§ªí¨ì¤u§@ªí¤¤¤£¥¿±`

ª½±µ§ì°£®§ªí¨ì¤u§@ªí¤¤¤£¥¿±`

ªÑ²¼¦WºÙ¤£¥¿±`
Sub Ä_¨Ó°£®§ªí()
Application.ScreenUpdating = False   '°£Åv°£®§ªí
Application.EnableEvents = False
Application.DisplayStatusBar = False
ActiveSheet.DisplayPageBreaks = 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://jdata.yuanta.com.tw/z/ze/zeb/zeb.djhtm"
        Do While .Busy Or .readyState <> 4: DoEvents: Loop
        Set Element = .Document.getElementsByTagName("table")
        On Error Resume Next
        Sheets("sheet1").Range("a:e").ClearContents
        With Sheets("sheet1")
                 For S = 2 To 2                    '¤w§ä¥Xºô­¶ªºtable¤º®e¦b 0-3 ¤¤
                For i = 1 To Element(S).Rows.Length - 1
                    k = k + 1
                   For j = 0 To 4   '¸ê®ÆªºÄæ¦ì¦@6¦ì
                        .Cells(k, j + 1) = Element(S).Rows(i).Cells(j).innerText
                    Next
                Next
            Next
        End With
       .Quit
    End With
    Set Element = Nothing
   
Application.DisplayStatusBar = True
End Sub
Book2.rar (20.52 KB)

Sub Click_1()
Dim ie
Sheets(1).Select
    Const url As String = "http://jdata.yuanta.com.tw/z/ze/zeb/zeb.djhtm"     ' ¥¿½Tªº
    Cells.Delete 'Clear
    Set ie = CreateObject("internetexplorer.application") '¨Ï¥Î¦¹¤è¦¡¥i¥H§K°£ "³]©w¤Þ¥Î¶µ¥Ø"
    With ie
        .Visible = False 'True¬°¶}±Òie, False¬°¤£¶}±Òie
        .Navigate url
        Do While .Busy Or .ReadyState <> 4: DoEvents: Loop ' Do While .ReadyState <> 4 'µ¥«Ýºô­¶¶}±Ò
        DoEvents
      '  Loop
        .ExecWB 17, 2 'Select All
        .ExecWB 12, 2 'Copy selection
         Range("A1").Activate
        ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
    End With
    Columns("A:A").Delete    ' ±N¶×¤J®É A¡BB ¨âÄæ²¾°£¡A ­ì¥» C:I ªºÄæ¦ì¥þ³¡¥ª¾a¡A ¦¨¬° A:I
    ie.Quit
End Sub

TOP

Sub Click_1()
Dim ie
Sheets(1).Select
    Const url As String = "http://jdata.yuanta.com.tw/z/z ...
f3202 µoªí©ó 2017-6-22 13:09

ÁÂÁ¡A§Ú¥u­n«e5Äæ A-E ­n§ï¨º¨Ç¦a¤è©O?

TOP

  1. Sub Ä_¨Ó°£®§ªí()
  2. Application.ScreenUpdating = False   '°£Åv°£®§ªí
  3. Application.EnableEvents = False
  4. Application.DisplayStatusBar = False
  5. ActiveSheet.DisplayPageBreaks = False
  6.     Dim i As Integer, S As Integer, k As Integer, j As Integer
  7.     Dim Element
  8.       With CreateObject("InternetExplorer.Application")
  9.         '.Visible = True           '¥iÅã¥Üºô­¶
  10.        .Navigate "http://jdata.yuanta.com.tw/z/ze/zeb/zeb.djhtm"
  11.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  12.         Set Element = .Document.getElementsByTagName("table")(2) ' ¤w§ä¥Xºô­¶ªºtable¤º®e¦b 0-3 ¤¤
  13.         Sheets("sheet1").Cells.ClearContents
  14.         With Sheets("sheet1")
  15.             For i = 1 To Element.Rows.Length - 1
  16.                 For j = 0 To Element.Rows(i).Cells.Length - 1
  17.                     If j = 0 And i > 2 Then
  18.                         .Cells(i, j + 1) = Element.all.tags("a")(i - 3).innertext
  19.                     Else
  20.                         .Cells(i, j + 1) = Element.Rows(i).Cells(j).innertext
  21.                     End If
  22.                 Next
  23.             Next
  24.         End With
  25.        .Quit
  26.     End With
  27.     Set Element = Nothing
  28.    
  29. Application.DisplayStatusBar = True
  30. End Sub
½Æ»s¥N½X
¦^´_ 1# t8899
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¥Í®ð¡A´N¬O®³§O¤Hªº¹L¿ù¨ÓÃg»@¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD