My Excel 2010 Only added when opening an empty workbook. Will not appear when opening an existing document

We made an excel add-on that was installed correctly and will only appear when Excel is opened from the main icon (or empty workbook). It will not appear on the toolbar when opening any saved Excel document.

I made sure that when opening an existing document, in the file β†’ options β†’ add in, it is correctly checked in the addition of COM. So that we can use our supplement, we need to open an empty book and drag our existing file into an empty book.

Can anyone think why it will only appear in the tape on an empty book, and not on existing .xlsx files?

I even checked the test, where I open an empty book, confirm that the addition is on the tape, put some text in the cell, save it on the desktop, close it and open it again. Then it does NOT appear. This addition was made with VS2010.

Here is the code from "ThisAddIn.cs"

public partial class ThisAddIn { private void ThisAddIn_Startup(object sender, System.EventArgs e) { } private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { } #region VSTO generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InternalStartup() { this.Startup += new System.EventHandler(ThisAddIn_Startup); this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); } #endregion } 

Here is the code from the Ribbon.cs file that we created ... everything that it does, fills in several fields and sets up:

 private void MyRibbon_Load(object sender, RibbonUIEventArgs e) { Excel._Workbook activeWorkbook = (Excel._Workbook)Globals.ThisAddIn.Application.ActiveWorkbook; if (activeWorkbook.Path == "") { string pathMyDocuments = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments); this.editBox1.Text = pathMyDocuments; } else { this.editBox1.Text = activeWorkbook.Path; this.fileBox.Text = "Converted_" + activeWorkbook.Name; } this.folderBrowserDialog1.RootFolder = System.Environment.SpecialFolder.MyComputer; this.folderBrowserDialog1.ShowNewFolderButton = true; //populate the dropdown box with spreadsheet templates using (SqlConnection conn = new SqlConnection("<removed for stack overflow>")) { using (SqlCommand command = new SqlCommand("<sql command text removed for SO", conn)) { command.CommandType = CommandType.Text; conn.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { RibbonDropDownItem item = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem(); item.Label = reader["MasterSpreadsheetName"].ToString(); ddlSpreadsheetTemplate.Items.Add(item); } } } } 
+6
source share
1 answer

Sorry for the late answer, but this is a very common problem, so I will answer anyway. I met him myself several times, and this had nothing to do with the code of my supplement. The problem was in the preview area in Explorer. enter image description here When you select the excel file in Explorer, it launches the Excel instance for preview. And then you open your file in real Excel, some error in Excel prevents all add-ons from loading. Your addin doesn't even run any code, so you cannot do anything from within your add-on. The only way is not to use preview with excel files. And even worse, after previewing one file, the Excel process still freezes in memory, so addins will not work until you kill it from the taskmanager. This error is in Excel 2007, 2010, 1013, and possibly even in 2016.

+1
source

All Articles