VBA插入.csv不起作用

我试图从这个URL导入.csv:

http://www.redfin.com/stingray/do/gis-search?market=socal&region_id=11203&region_type=6&excl_ss=true&hoa=&max_listing_approx_size=&max_num_beds=&max_parcel_size=&max_price=300000&max_year_built=&min_listing_approx_size=&min_parcel_size=&min_price=50000&min_year_built=&num_baths=1.0&num_beds = 1&open_house =&PKG = – &RD = SF = 1%2C2%2C3&sold_within_days =&状态= 1&time_on_market_range = 30-&uipt = 2&v = 8&num_homes = 500& SP = T&人= 3&渲染= CSV

以下代码适用于我使用不同的.csvurl,如下所示: http : //ichart.finance.yahoo.com/table.csv?s=AAPL&d=2&e=13&f=2013&g=d&a=8&b=7&c=1984&ignore =的.csv

但是,代码不适用于更长的URL。 该url是否过长? 如果是这样,是否有解决方法?

这是我现在的代码:

Sub importCSV() Dim URL As String URL = "TEXT;http://www.redfin.com/stingray/do/gis-search?market=socal&region_id=11203&region_type=6&excl_ss=true&hoa=&max_listing_approx_size=&max_num_beds=&max_parcel_size=&max_price=300000&max_year_built=&min_listing_approx_size=&min_parcel_size=&min_price=50000&min_year_built=&num_baths=1.0&num_beds=1&open_house=&pkg=-&rd=&sf=1%2C2%2C3&sold_within_days=&status=1&time_on_market_range=30-&uipt=2&v=8&num_homes=500&sp=t&al=3&render=csv" Application.DisplayAlerts = False With ActiveSheet.QueryTables.Add(Connection:=URL, _ Destination:=Range("A1")) .Name = "test" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlOverwriteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 437 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = False .TextFileTabDelimiter = False .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = True .TextFileSpaceDelimiter = False .TextFileColumnDataTypes = Array(1, 1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With Application.DisplayAlerts = True End Sub 

马特

尝试这个:

 With ActiveSheet.QueryTables.Add(Connection:= _ "URL;[your url goes here]", Destination:=Range("$A$1")) .Name = "home" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlEntirePage .WebFormatting = xlWebFormattingNone .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With 

这适用于Excel 2010。