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;
source share