返回列表 上一主題 發帖

[發問] 無法匯入PCHOME 股市資料

回復 9# tajen
提供參考: (不知是否吻合你的需求?)
  1. Sub 最佳五檔()
  2.     Dim Sh As Worksheet
  3.    
  4.     Set Sh = Sheets("工作表3")                   '  可指定工作表
  5.    
  6.     With Sh
  7.         .Cells.Clear
  8.         .Select
  9.         
  10.         With .QueryTables.Add(Connection:= _
  11.             "URL;http://traderoom.cnyes.com/tse/quote2FB.aspx?code=6121", Destination:= _
  12.                                                                           .Range("F1"))
  13.             .WebFormatting = xlWebFormattingNone
  14.             .WebTables = "7"
  15.             .Refresh BackgroundQuery:=False
  16.         End With
  17.         
  18.         With .QueryTables.Add(Connection:= _
  19.             "URL;http://traderoom.cnyes.com/tse/quote2FB.aspx?code=6121", Destination:= _
  20.                                                                           .Range("A1"))
  21.             .WebFormatting = xlWebFormattingNone
  22.             .WebTables = "8,10,11"    '  網頁的表格,更改 WebTables 就行了
  23.             '  .WebTables = "7,8,10,11"
  24.             '  .WebTables = "6,8,10,11"
  25.             .Refresh BackgroundQuery:=False
  26.         End With
  27.         
  28.         With .QueryTables.Add(Connection:= _
  29.             "URL;http://traderoom.cnyes.com/tse/quote2FB.aspx?code=6121", Destination:= _
  30.                                                                           .Range("I1"))
  31.             .WebFormatting = xlWebFormattingNone
  32.             .WebTables = "6"
  33.             .Refresh BackgroundQuery:=False
  34.         End With
  35.         
  36.         .Range("A:N").EntireColumn.AutoFit
  37.     End With
  38. End Sub
複製代碼

TOP

回復 9# tajen
將以下文字複製於[小作家]或[記事本] 存檔為 "價量圖.iqy" (.iqy 查詢檔的副檔名)後,請雙擊 "價量圖.iqy".
ps:那一行空白是必須的
  1. WEB
  2. 1
  3. http://traderoom.cnyes.com/tse/quote2FB.aspx?code=["價量圖","請輸入股票代號:如 2317"]

  4. Selection=7
  5. Formatting=None
  6. PreFormattedTextToColumns=True
  7. ConsecutiveDelimitersAsOne=True
  8. SingleBlockTextImport=False
  9. DisableDateRecognition=False
  10. DisableRedirections=False
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

回復 12# GBKEE

Microsoft Office Excel could not open or read this query file. Either the file has been damaged or the file format is not valid :(

TOP

回復 13# genes
一樣是 2003版 ,為何你的不行

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

TOP

回復 14# GBKEE


    原來是英文版office和中文版的不兼容, 改成英文可以. 有沒有辦法能兼容?

另外iqy在那裡可以學到? 沒有聽過

TOP

To:joey0415 大大
    謝謝您告知webtables=7,我沒想到可以這樣推算,感恩。

To: GBKEE大大
    真的是太完美了,又多學了一些,真的很感謝。甘恩啦!!!

TOP

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

TOP

請教 G大大 , 如果輸入錯誤股票代碼 網頁顯示查無資料 導致停在 DoEvents 無限迴圈 如何加入錯誤檢查"查無資料" 謝謝

.Navigate "http://pchome.syspower.com.tw/stock/sto0/ock2/sid" & Stock & ".html"
        .Visible = True
        Do While .Busy Or .ReadyState <> 4
             DoEvents
        Loop

TOP

回復 18# chairmen100
  1.   With CreateObject("InternetExplorer.application")
  2.         .Navigate "http://pchome.syspower.com.tw/stock/sto0/ock2/sid" & Stock & ".html"
  3.         .Visible = True
  4.         T = Time
  5.         Do While .Busy Or .ReadyState <> 4
  6.              DoEvents
  7.              If Time - T > #12:00:05 AM# Then End  '超過5秒 停止程序
  8.         Loop
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

GBKEE 大大
請問為何我使用你的程式碼還是無法匯入http://pchome.syspower.com.tw/stock/sto2/ock2/sid2330.html
這網頁的資料,是哪錯了?
難道需要特別的設定或步驟???
可否指導一下。

TOP

        靜思自在 : 要比誰更受誰.不要比誰更怕誰。
返回列表 上一主題