我正在尝试从此 URL 导入 .csv:
下面的代码在我使用不同的 .csv URL 时有效,例如: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。网址是否太长?如果是这样,是否有解决方法?
这是我当前的代码:
Sub importCSV()
Dim URL As String
URL = "TEXT;http://www.redfin.com/stingray/do/gis-search?market=socal®ion_id=11203®ion_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
马特