Why change file2 status, file1 also changes in Ribbon on word add in VSTO

69 views Asked by At

I've create two buttons in my Word add-in ribbon : Status button with default "Open" and ChangeStatus button.

I open two file to test. I click ChangeStatus button file2 to Close, file1 also changes to Close.

How can I force the file 1 to display Open not Close when I click ChangeStatus button on file2. (only status button file2 change to "Close")

enter image description here

Demo.cs:

using System.Windows.Forms;
using Microsoft.Office.Tools.Ribbon;
using Office = Microsoft.Office.Core;
namespace TestWordAddIn
{
    public partial class Demo
    {
        private Responsive responsive;
        private Detail myDetail;
        private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane;
        private void Demo_Load(object sender, RibbonUIEventArgs e)
        {
            responsive = new Responsive(Screen.PrimaryScreen.Bounds);
            responsive.SetMultiplicationFactor();
        }

        private void btnStatus_Click(object sender, RibbonControlEventArgs e)
        {
            myDetail = new Detail();

            myCustomTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(myDetail, "Error List");
            myCustomTaskPane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
            myCustomTaskPane.Width = responsive.GetMetrics(380);
            myCustomTaskPane.Visible = true;
        }

        private void btnChangeLable_Click(object sender, RibbonControlEventArgs e)
        {
            btnStatus.Label = "Close";
        }
    }
}

This code ThisAddIn.css:

namespace TestWordAddIn
{
    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
    }
}
0

There are 0 answers