none
Problem Loading Excel Add-In Through C# RRS feed

  • General discussion

  • I am running this code: And this is with VS2010 and Excel 2007 and I want to load the Excel Add-in pro grammatically through C#

    namespace Atempting
    {
                    public partial class Form1 : Form
                    {
                                    //Declaring Variables
                                    Excel.Application oXL;
                                    Excel._Workbook oWB;
                                    Excel._Worksheet oSheet;
                                    Excel.Range oRng;
                                    private void btntry_Click_1(object sender, EventArgs e)
                                    {
                                                    oXL = new Excel.Application();
                                                    oXL.Visible = true;
                                                    oWB = (Excel._Workbook)(oXL.Workbooks.Add(Missing.Value));
                                                    oSheet = (Excel._Worksheet)oWB.ActiveSheet;
     
                                                    //This sets the security for the Workbook you just created
                                                    oXL.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityLow;
                                                    //This is the location of the .xlam file that you want to run
                                                    oXL.Workbooks.Open(@"C:\\Excel\\Addin\\Excel_AddIn.xlam");
     
                                                    oRng = oSheet.get_Range("A1");
                                                    oXL.Visible = true;
                                                    oXL.UserControl = true;
                                                   
                                                    //more code here
                                    }
                    }
    }

    But it is not actually loading my add-in?  What did I mess up?


    Saturday, February 9, 2013 2:45 PM

All replies