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

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

¦³µL¿ìªk±N¦¹ºô­¶¶×¤JEXCEL ??

¥»©«³Ì«á¥Ñ t8899 ©ó 2014-1-9 07:31 ½s¿è

http://www.twse.com.tw/ch/trading/exchange/TWTB4U/TWTB4U.php  (ºô¯¸·í¤Ñ¸ê®Æ¤j¬ù21:00·|§ó·s)

TOP

¦^´_ 1# t8899

ªí®æ¤¤«ö¤U·Æ¹«¥kÁä

   
EX.JPG
2014-1-9 09:07
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_  t8899

ªí®æ¤¤«ö¤U·Æ¹«¥kÁä
GBKEE µoªí©ó 2014-1-9 09:08


¤é´Á§ï¬°1/8 ·|Åܦ¨¨â­Ó¸ê®Æ®Ø(³£»Ý­n¶×¤J)
²Ä¤@­Ó¶×¥X·|Åܦ¨1/9 (·í¤é)(¤µ¤é¸ê®Æ±ß¤W¤~·|update)
²Ä¤G­Ó¶×¥X·|Åܦ¨"¦¹web¨S¦³¶Ç¦^¸ê®Æ............"

Snap1.jpg
2014-1-9 14:37

TOP

¦^´_ 3# t8899
  1. Option Explicit
  2. Sub TWSE_¥æ©ö¸ê°T()
  3.     Dim YMD_day As String, N As Name, webURL As String
  4.     YMD_day = InputBox("¿é¤J ¥Á°ê¦~«× : 102/10/07", "¤U¸ü¯S©w¤é´Áªº¸ê®Æ", Format(Date - 1, "E/MM/DD")) '¥Á°ê¦~«× "102/10/07"
  5.     With ActiveSheet  '¥i«ü©w¤u§@ªí
  6.         '·í¤é¨R¾P¥æ©ö¼Ðªº¤Î²Î­p
  7.         webURL = "URL;http://www.twse.com.tw/ch/trading/exchange/TWTB4U/TWTB4U.php?input_date=" & YMD_day & "&login_btn=¬d¸ß.dat"
  8.         '¹dÃB¥æ©ö¤é¦¨¥æ¸ê°T
  9.         'webURL = "URL; http://www.twse.com.tw/ch/trading/block/BFIAUU/BFIAUU.php?input_date=" & YMD_day & "&login_btn=¬d¸ß.dat"
  10.         'webURL = "URL; http://www.twse.com.tw/ch/trading/block/BFIAUU/BFIAUU.php?input_date=" & YMD_day & "&login_btn=%ACd%B8%DF.dat"
  11.         If .QueryTables.Count = 0 Then
  12.             .QueryTables.Add Connection:=webURL, Destination:=.Range("A1")
  13.         Else
  14.             .QueryTables(1).Connection = webURL
  15.         End If
  16.         .Cells.Clear
  17.         With .QueryTables(1)
  18.             .WebSelectionType = xlSpecifiedTables
  19.             .WebFormatting = xlWebFormattingNone
  20.            ' .WebTables = "data_table"  '¹dÃB¥æ©ö¤é¦¨¥æ¸ê°T     :¸ê®Æ¶×¤JªºTables
  21.             .WebTables = "9,11"         '·í¤é¨R¾P¥æ©ö¼Ðªº¤Î²Î­p :¸ê®Æ¶×¤JªºTables
  22.             .Refresh BackgroundQuery:=False
  23.         End With
  24.     End With
  25. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_  t8899
GBKEE µoªí©ó 2014-1-9 15:43


±z¤]§â¹dÃB¥æ©ö¤é¦¨¥æ¸ê°T¤]©ñ¶i¨Ó, ÁÂÁÂ

TOP

¦^´_  t8899
GBKEE µoªí©ó 2014-1-9 15:43

¦A½Ð±Ð¤@¤U¡A¦p¦ó¤£­n¦Û°Ê½Õ¾ãÄæ¼e??

TOP

¦^´_ 6# t8899

¦bwith ¸Ì­±¥[¤W .AdjustColumnWidth = False¡A´N¦n¤F¡A¥i¥H¦Û¤v¥Î¿ý»s¥¨¶°¬Ý¬Ý¿ý¥X¤°»òµ{¦¡½X


Option Explicit
Sub TWSE_¥æ©ö¸ê°T()
    Dim YMD_day As String, N As Name, webURL As String
    YMD_day = InputBox("¿é¤J ¥Á°ê¦~«× : 102/10/07", "¤U¸ü¯S©w¤é´Áªº¸ê®Æ", Format(Date - 1, "E/MM/DD")) '¥Á°ê¦~«× "102/10/07"
    With ActiveSheet  '¥i«ü©w¤u§@ªí
        '·í¤é¨R¾P¥æ©ö¼Ðªº¤Î²Î­p
        webURL = "URL;http://www.twse.com.tw/ch/trading/exchange/TWTB4U/TWTB4U.php?input_date=" & YMD_day & "&login_btn=¬d¸ß.dat"
        '¹dÃB¥æ©ö¤é¦¨¥æ¸ê°T
        'webURL = "URL; http://www.twse.com.tw/ch/trading/block/BFIAUU/BFIAUU.php?input_date=" & YMD_day & "&login_btn=¬d¸ß.dat"
        'webURL = "URL; http://www.twse.com.tw/ch/trading/block/BFIAUU/BFIAUU.php?input_date=" & YMD_day & "&login_btn=%ACd%B8%DF.dat"
        If .QueryTables.Count = 0 Then
            .QueryTables.Add Connection:=webURL, Destination:=.Range("A1")
        Else
            .QueryTables(1).Connection = webURL
        End If
        .Cells.Clear
        With .QueryTables(1)
            .AdjustColumnWidth = False
            .WebSelectionType = xlSpecifiedTables
            .WebFormatting = xlWebFormattingNone
           ' .WebTables = "data_table"  '¹dÃB¥æ©ö¤é¦¨¥æ¸ê°T     :¸ê®Æ¶×¤JªºTables
            .WebTables = "9,11"         '·í¤é¨R¾P¥æ©ö¼Ðªº¤Î²Î­p :¸ê®Æ¶×¤JªºTables
            .Refresh BackgroundQuery:=False
        End With
    End With
End Sub

TOP

¤é´Á§ï¬°1/8 ·|Åܦ¨¨â­Ó¸ê®Æ®Ø(³£»Ý­n¶×¤J)
²Ä¤@­Ó¶×¥X·|Åܦ¨1/9 (·í¤é)(¤µ¤é¸ê®Æ±ß¤W¤~·|update)
²Ä ...
t8899 µoªí©ó 2014-1-9 14:37

½Ð±Ð¤@¤U
1 ==> webURL = "URL;http://www.twse.com.tw/ch/trading/exchange/TWTB4U/TWTB4U.php

2 ==>  With CreateObject("InternetExplorer.Application")
   .Navigate "http://newmis.twse.com.tw/stock/group.jsp?ex=tse&ind=TIDX#STATISTICS"

1,2¦³¦ó¤£¦P?? ²Ä¤G­Ó¥i¥H¥Î§ï¥Î²Ä¤@­Ó¤èªk ??

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

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

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

CreateObject("InternetExplorer.Application") °õ¦æ§¹¦³®É·|µLªk¸õ¥X??
¦³®É·|¦b°O¾ÐÅé¸Ì???¦pªG¤£²z¥¦¡A·|¶V¨Ó¶V¦h­Óiexplorer.exe ¨ì³Ì«á·|¥X²{¿ù»~.............

Option Explicit
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")
        On Error Resume Next
              With Sheets("sheet5")
           .Cells.CLEAR
                '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 5   '¸ê®ÆªºÄæ¦ì¦@6¦ì
                         .Cells(K, j + 1) = Element(S).Rows(i).Cells(j).innerText
                        '********************************************
                        '¤£ª¾¦¹ºô­¶ªºtable¤º®e:¥ý¦æ¦C¥X table ¦ì¸m  *
                        'Sheets(2).Cells(k, J + 1) = s             '*
                        '********************************************
                    Next
               Next
            Next
     '       .Cells.EntireColumn.AutoFit            '¦Û°Ê½Õ¾ãÄæ¼e
      '      .Cells.EntireRow.AutoFit               '¦Û°Ê½Õ¾ã¦C°ª
        End With
       .Quit
    End With
    Set Element = Nothing
  '  MsgBox "0K"
End Sub
Snap1.jpg
2014-1-13 11:54

        ÀR«ä¦Û¦b : ¤Hªº¤ß¦a¬O¤@²¥¥Ð¡A¤g¦a¨S¦³¼½¤U¦nºØ¤l¡A¤]ªø¤£¥X¦nªºªG¹ê¡C -
ªð¦^¦Cªí ¤W¤@¥DÃD