-2

I am trying to create a custom task pane in Excel 2016.As far as I see, there is same code all site to create it.But common problem is taskpane is unvisible. The code doesn't give any error.

help please

murat turna
  • 15
  • 1
  • 7

2 Answers2

0

In AddIns:

    private TaskWaterMark taskPaneControl1;
    private Microsoft.Office.Tools.CustomTaskPane taskPaneValue;


    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        taskPaneControl1 = new TaskWaterMark();
        taskPaneValue = this.CustomTaskPanes.Add(taskPaneControl1, "MyCustomTaskPane");
        taskPaneValue.Visible = true;
        //taskPaneValue.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionFloating;
        //taskPaneValue.Height = 500;
        //taskPaneValue.Width = 500;
        //taskPaneValue.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
        //taskPaneValue.Width = 300;
        this.Application.WorkbookActivate += new Excel.AppEvents_WorkbookActivateEventHandler(Application_WorkbookActivate);
        taskPaneValue.VisibleChanged +=new EventHandler(taskPaneValue_VisibleChanged);
    }


    private void Application_WorkbookActivate(Microsoft.Office.Interop.Excel.Workbook wb)
    {
    }


    public void taskPaneValue_VisibleChanged(object sender, System.EventArgs e)
    {
        Globals.Ribbons.Ribbon1.toggleButton2.Checked = taskPaneValue.Visible;
    }

    public Microsoft.Office.Tools.CustomTaskPane TaskPane
    {
        get { return taskPaneValue;}
    }

In Rıbbon:

private void toggleButton2_Click(object sender, RibbonControlEventArgs e)
{
        Globals.ThisAddIn.TaskPane.Visible = ((RibbonToggleButton)sender).Checked;

}
Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
murat turna
  • 15
  • 1
  • 7
-1

Did you try to debug the code? Do you get any exceptions in the code?

The fact is that Office may disable the add-in automatically if it fires an exception at startup. Here is what you may see in MSDN:


Microsoft Office applications can disable VSTO Add-ins that behave unexpectedly. If an application does not load your VSTO Add-in when you try to debug it, the application might have hard disabled or soft disabled your VSTO Add-in.

Hard disabling can occur when an VSTO Add-in causes the application to close unexpectedly. It might also occur on your development computer if you stop the debugger while the Startup event handler in your VSTO Add-in is executing.

Soft disabling can occur when a VSTO Add-in produces an error that does not cause the application to unexpectedly close. For example, an application might soft disable a VSTO Add-in if it throws an unhandled exception while the Startup event handler is executing.

When you re-enable a soft-disabled VSTO Add-in, the application immediately attempts to load the VSTO Add-in. If the problem that initially caused the application to soft disable the VSTO Add-in has not been fixed, the application will soft disable the VSTO Add-in again.


Read more about that in the How to: Re-enable a VSTO Add-in That Has Been Disabled article.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45