返回列表 上一主題 發帖

[發問] 請問這種匯入外部資料web要如何做到

本帖最後由 GBKEE 於 2013-5-22 15:02 編輯

回復 5# stillfish00
TextFileStartRow 須是匯入文字檔,這網頁不適用
回復 3# freeffly
回復 4# seemee
  1. Option Explicit
  2. Sub Ex()
  3.     With ActiveSheet
  4.         With .QueryTables.Add(Connection:="URL;http://www.taifex.com.tw/chinese/3/3_2_2.asp", Destination:=[A1])
  5.             '**********  .WebSelectionType     有3個參數數值 *************
  6.             If .Parent.QueryTables.Count = 1 Then
  7.                 .WebSelectionType = xlEntirePage                '匯入整個網頁
  8.             ElseIf .Parent.QueryTables.Count = 2 Then
  9.                  .WebSelectionType = xlAllTables               '匯入網頁所有的表格
  10.             ElseIf .Parent.QueryTables.Count >= 3 Then
  11.                 .WebSelectionType = xlSpecifiedTables          '匯入指定的網頁的表格
  12.                 .WebTables = "3"            '匯入指定第3個表格      '=xlSpecifiedTables  才可用此參數
  13.             End If
  14.             '************************************************************
  15.             .WebFormatting = xlWebFormattingNone
  16.             .WebPreFormattedTextToColumns = True
  17.             .WebConsecutiveDelimitersAsOne = True
  18.             .WebSingleBlockTextImport = False
  19.             .WebDisableDateRecognition = False
  20.             .WebDisableRedirections = False
  21.             .Refresh BackgroundQuery:=False
  22.         End With
  23.         MsgBox "第" & .QueryTables.Count & "Web 查詢 網址" & .QueryTables(.QueryTables.Count).Connection
  24.     End With
  25. End Sub
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

        靜思自在 : 【是否發揮了良能?】人間壽命因為短暫,才更顯得珍貴。難得來一趟人間,應問是否為人間發揮了自己的良能,而不要一味求長壽。
返回列表 上一主題