none
excel addins RRS feed

  • Question

  • Hi,
    I am trying to open an existing excel spreadsheet which has an Addins.
    When I open it using .net code, it opens the file but the addins does not appear in the file.

    So, after doing some search, I found there is a VBA code which does what I want but unfortunately I do not know how to add this VBA code to my .net code.
    I am using c# but you can let me know the code in vb.net if you prefer.

    Thanks

    Here is the VBA which is supposed to have the Addins in the excel file:

    Dim oAddin As AddIn
    Dim oTempBk As Workbook

    Set oTempBk = Workbooks.Add

    Set oAddin = oXL.AddIns.Add("C:\blp\blp.xla", True)
    oAddin.Installed = True

    oTempBk.Close


    In case you are interested, I am using c# to open my current excel file:

    Microsoft.Office.Interop.Excel.Application EApp = new Microsoft.Office.Interop.Excel.Application();
                    Microsoft.Office.Interop.Excel.Worksheet WS = ((Microsoft.Office.Interop.Excel.Worksheet)(EApp.Workbooks.Open(@"C:\MarketAnalytics\YieldsSpreads\YieldsSpreads.xls",
                                                                Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing).ActiveSheet));

    EApp.Visible = true;

    Wednesday, February 6, 2008 8:32 AM

Answers

  • Add followings after your C# codes:

    Code Snippet
                Excel.AddIn addIn = EApp.AddIns.Add(@"C:\blp\blp.xla", Type.Missing);
                addIn.Installed = true;

     

     

    Thanks

    Ji

    Friday, February 8, 2008 6:27 AM
    Moderator