Excel interop loading XLLs and DLLs

后端 未结 4 1506
南笙
南笙 2020-12-03 04:14

I have excel with the Bloomberg API ( which uses simple calls like =BDP(\"MS equity\",\"ask\") ). I also have a C# application that opens an excel file (through interop) tha

4条回答
  •  遥遥无期
    2020-12-03 04:44

    I realize that it's been while since this question has been asked. Nevertheless I want to share my experience as I came across the same problem. An easy solution is to proceed as suggested in https://blogs.msdn.microsoft.com/accelerating_things/2010/09/16/loading-excel-add-ins-at-runtime/ by first setting .Installed to false and then to true:

    this._application = new Application
                    {
                        EnableEvents = true,
                        Visible = true
                    };
    
                    //Load Bloomberg Add-In
                    for (var i = 1; i <= this._application.AddIns.Count; i++)
                    {
                        var currentAddIn = this._application.AddIns.Item[i];
    
                        if (currentAddIn.Name != "BloombergUI.xla") continue;
    
                        currentAddIn.Installed = false;
                        currentAddIn.Installed = true;
                    }
    

提交回复
热议问题