返回列表 上一主題 發帖

[發問] 資料抓取另存在不同sheet, 出現錯誤1004

請問前輩

依照這樣的作法,修改了另外一個檔案
程式碼可以執行,但是全部都貼在sheet1
而非指定的CFQ, INC, ISQ, BSQ當中
這是程式碼哪個地方沒指定清楚呢?

Private Sub CommandButton1_Click()

    With Sheets("CFSQ")
        With QueryTables.Add(Connection:= _
            "URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_2002.djhtm", Destination:=Range( _
            "$A$1"))
            .Name = "zc3_2002.djhtm"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = True
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .WebSelectionType = xlSpecifiedTables
            .WebFormatting = xlWebFormattingNone
            .WebTables = "3"
            .WebPreFormattedTextToColumns = True
            .WebConsecutiveDelimitersAsOne = True
            .WebSingleBlockTextImport = False
            .WebDisableDateRecognition = False
            .WebDisableRedirections = False
            .Refresh BackgroundQuery:=False
        End With
    End With
   
    With Sheets("ISQ")
        With QueryTables.Add(Connection:= _
            "URL;http://dj.mybank.com.tw/z/zc/zcq/zcq_2002.asp.htm", Destination:=Range( _
            "$A$1"))
            .Name = "zcq_2002.asp"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = True
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .WebSelectionType = xlSpecifiedTables
            .WebFormatting = xlWebFormattingNone
            .WebTables = "3"
            .WebPreFormattedTextToColumns = True
            .WebConsecutiveDelimitersAsOne = True
            .WebSingleBlockTextImport = False
            .WebDisableDateRecognition = False
            .WebDisableRedirections = False
            .Refresh BackgroundQuery:=False
        End With
    End With
   
    With Sheets("BSQ")
        With QueryTables.Add(Connection:= _
            "URL;http://dj.mybank.com.tw/z/zc/zcp/zcpa/zcpa_2002.asp.htm", Destination:= _
            Range("$A$1"))
            .Name = "zcpa_2002.asp"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = True
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .WebSelectionType = xlSpecifiedTables
            .WebFormatting = xlWebFormattingNone
            .WebTables = """oMainTable"""
            .WebPreFormattedTextToColumns = True
            .WebConsecutiveDelimitersAsOne = True
            .WebSingleBlockTextImport = False
            .WebDisableDateRecognition = False
            .WebDisableRedirections = False
            .Refresh BackgroundQuery:=False
        End With
    End With
   
    With Sheets("INC")
        With QueryTables.Add(Connection:= _
            "URL;http://dj.mybank.com.tw/z/zc/zch/zch_2002.asp.htm", Destination:=Range( _
            "$A$1"))
            .Name = "zch_2002.asp"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = True
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .WebSelectionType = xlSpecifiedTables
            .WebFormatting = xlWebFormattingNone
            .WebTables = """oMainTable"""
            .WebPreFormattedTextToColumns = True
            .WebConsecutiveDelimitersAsOne = True
            .WebSingleBlockTextImport = False
            .WebDisableDateRecognition = False
            .WebDisableRedirections = False
            .Refresh BackgroundQuery:=False
        End With
    End With
   
End Sub

TOP

不好意思
我知道了
爬過文,眼睛太大顆沒發現 "."的存在
>"<

TOP

        靜思自在 : 欣賞別人就是莊嚴自己。
返回列表 上一主題