我正在尝试填充Excel具有的MSN数据连接。我想从另一张表中复制一个符号列表,并在数据源中使用它,就像我用逗号分隔一样,以获取最新价格。
这是数据Feed宏,但我无法弄清楚如何输入符号。
With ActiveSheet.QueryTables.Add(Connection:= _
"FINDER;C:\Program Files\Microsoft Office\Office14\QUERIES\MSN MoneyCentral Investor Stock Quotes.iqy" _
, Destination:=Range("$A$1"))
.Name = "MSN MoneyCentral Investor Stock Quotes"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 1
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = True
.Refresh BackgroundQuery:=False
End With
End Sub
答案 0 :(得分:1)
如果从Sheet1运行此操作,并且股票符号范围在Sheet2中 您在问题中引用的文件
“C:\ Program Files \ Microsoft Office \ Office14 \ QUERIES \ MSN MoneyCentral Investor Stock Quotes.iqy”
如果你打开它,无论如何都会引用这个底层URL,所以只需在本地跳过引用并使用它,它也适用于不同的版本。
Sub getQuotes()
Dim quotStr
For Each cell In Sheets("Sheet2").Range("A1:A5") 'whatever range you want
quotStr = cell + ", " + quotStr
Next
quotStr = Left(quotStr, (Len(quotStr) - 2))
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://moneycentral.msn.com/investor/external/excel/quotes.asp?SYMBOL=" & quotStr _
, Destination:=Range("$A$1"))
.Name = "MSN MoneyCentral Investor Stock Quotes"
---等