0

我正在尝试填充 Excel 拥有的 MSN 数据连接。我想从另一张表中复制符号列表并在数据馈送中使用它,就像我用逗号分隔一样,以获取最新价格。

这是数据馈送宏,但我不知道如何输入符号。

 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
4

1 回答 1

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"

- -ETC

于 2012-07-17T18:55:08.083 回答