Excel Custom Task Pane not showing

2019-02-10 18:44发布

I'm showing a custom task pane in an excel VSTO add-in, I'm building it and showing it as thus:

var ctrl = new CellTaskPane();
var pane = CustomTaskPanes.Add(ctrl, "Custom Sheet");
pane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
pane.DockPositionRestrict = Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoChange;
pane.Visible = true;

This is being done in the ThisAddin.cs file and it working just fine on my machine, both under a Debug session and with the add-in installed via the click-once installer.

However, installing the add-in on a colleague's machine is proving troublesome.

The add-in is functioning and the context menu / ribbon is working perfectly, but the pane just refuses to show.

I have a toggle button on the ribbon which toggles the Visible property on the pane and even clicking that isn't forcing the pane to show.

Any help on this would be greatly appreciated, Google is proving useless for this.

Thanks.


I should mention that CellTaskPane is just a UserControl as per the docs on MSDN: http://msdn.microsoft.com/en-us/library/aa942846.aspx

8条回答
该账号已被封号
2楼-- · 2019-02-10 19:46

I had the same problem, but it was not any addin I could disable (COM+ or Excel).

I had my excel configured to open files at startup (Excel Options -> Advanced -> General)

enter image description here

There, I had an .XLAM that customized the ribbon. When I cleared this configuration, my addin started working.

查看更多
Summer. ? 凉城
3楼-- · 2019-02-10 19:46

Create a new instance of the task pane for each workbook. Make the following changes to your code and the task pane works even with addins enabled.

private void Application_WorkbookActivate(Microsoft.Office.Interop.Excel.Workbook wb)
{
    pane = CustomTaskPanes.Add(ctrl, "Custom Sheet");
    pane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
    pane.DockPositionRestrict = Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoChange;
    pane.Visible = true;
    pane.VisibleChanged += new EventHandler(taskPaneValue_VisibleChanged);
    ctrl.SetName("test");
}

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
    this.Application.WorkbookActivate += new Excel.AppEvents_WorkbookActivateEventHandler(
        Application_WorkbookActivate);
}
查看更多
登录 后发表回答