返回列表 上一主題 發帖

[發問] CreateObject("InternetExplorer.Application") 執行完有時會無法跳出??

日期改為1/8 會變成兩個資料框(都需要匯入)
第一個匯出會變成1/9 (當日)(今日資料晚上才會update)
第 ...
t8899 發表於 2014-1-9 14:37

請教一下
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有何不同?? 第二個可以用改用第一個方法 ??

TOP

回復 6# t8899

在with 裡面加上 .AdjustColumnWidth = False,就好了,可以自己用錄製巨集看看錄出什麼程式碼


Option Explicit
Sub TWSE_交易資訊()
    Dim YMD_day As String, N As Name, webURL As String
    YMD_day = InputBox("輸入 民國年度 : 102/10/07", "下載特定日期的資料", Format(Date - 1, "E/MM/DD")) '民國年度 "102/10/07"
    With ActiveSheet  '可指定工作表
        '當日沖銷交易標的及統計
        webURL = "URL;http://www.twse.com.tw/ch/trading/exchange/TWTB4U/TWTB4U.php?input_date=" & YMD_day & "&login_btn=查詢.dat"
        '鉅額交易日成交資訊
        'webURL = "URL; http://www.twse.com.tw/ch/trading/block/BFIAUU/BFIAUU.php?input_date=" & YMD_day & "&login_btn=查詢.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"  '鉅額交易日成交資訊     :資料匯入的Tables
            .WebTables = "9,11"         '當日沖銷交易標的及統計 :資料匯入的Tables
            .Refresh BackgroundQuery:=False
        End With
    End With
End Sub

TOP

回復  t8899
GBKEE 發表於 2014-1-9 15:43

再請教一下,如何不要自動調整欄寬??

TOP

回復  t8899
GBKEE 發表於 2014-1-9 15:43


您也把鉅額交易日成交資訊也放進來, 謝謝

TOP

回復 3# t8899
  1. Option Explicit
  2. Sub TWSE_交易資訊()
  3.     Dim YMD_day As String, N As Name, webURL As String
  4.     YMD_day = InputBox("輸入 民國年度 : 102/10/07", "下載特定日期的資料", Format(Date - 1, "E/MM/DD")) '民國年度 "102/10/07"
  5.     With ActiveSheet  '可指定工作表
  6.         '當日沖銷交易標的及統計
  7.         webURL = "URL;http://www.twse.com.tw/ch/trading/exchange/TWTB4U/TWTB4U.php?input_date=" & YMD_day & "&login_btn=查詢.dat"
  8.         '鉅額交易日成交資訊
  9.         'webURL = "URL; http://www.twse.com.tw/ch/trading/block/BFIAUU/BFIAUU.php?input_date=" & YMD_day & "&login_btn=查詢.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"  '鉅額交易日成交資訊     :資料匯入的Tables
  21.             .WebTables = "9,11"         '當日沖銷交易標的及統計 :資料匯入的Tables
  22.             .Refresh BackgroundQuery:=False
  23.         End With
  24.     End With
  25. End Sub
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

回復  t8899

表格中按下滑鼠右鍵
GBKEE 發表於 2014-1-9 09:08


日期改為1/8 會變成兩個資料框(都需要匯入)
第一個匯出會變成1/9 (當日)(今日資料晚上才會update)
第二個匯出會變成"此web沒有傳回資料............"

TOP

回復 1# t8899

表格中按下滑鼠右鍵

   
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

有無辦法將此網頁匯入EXCEL ??

本帖最後由 t8899 於 2014-1-9 07:31 編輯

http://www.twse.com.tw/ch/trading/exchange/TWTB4U/TWTB4U.php  (網站當天資料大約21:00會更新)

TOP

        靜思自在 : 時時好心就是時時好日。
返回列表 上一主題