A special Excel taskbar that does not display

I show the custom task pane in the Excel VSTO add-in, assemble it and show it like this:

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 done in a file ThisAddin.cs, and it works fine on my computer, both in a debugging session and with an add-in installed with a one-click installer.

However, installing an add-on on a colleague’s computer is problematic.

The add-in works, and the context menu / ribbon works fine, but the panel just doesn't appear.

I have a button on the ribbon that toggles a property Visibleon the panel and even a click that does not make the panel display.

Any help on this subject would be greatly appreciated; Google is of no use for this.

Thanks.


, CellTaskPane UserControl MSDN: http://msdn.microsoft.com/en-us/library/aa942846.aspx

+5
9

, , !

​​ ( ), - ( , ).

, Excel - , , .

.

+3

, , , . , , , , , .

, . VSTO " ". . :

ThisAddIn.cs

using System;
using Office = Microsoft.Office.Core;

namespace ExcelAddIn1
{
    public partial class ThisAddIn
    {
        private Microsoft.Office.Tools.CustomTaskPane pane;
        private CellTaskPane ctrl = new CellTaskPane();

        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            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 taskPaneValue_VisibleChanged(object sender, System.EventArgs e)
        {
            Globals.Ribbons.Ribbon1.toggleButton1.Checked = pane.Visible;
        }

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

        public CellTaskPane MyContainer
        {
            get
            {
                return ctrl;
            }
        }

        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
    }
}

CellTaskPane.cs:

using System;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

namespace ExcelAddIn1
{
    public class CellTaskPane : System.Windows.Forms.UserControl
    {
        public System.Windows.Forms.TextBox test;

        public CellTaskPane()
        {
            InitializeComponent();
        }

        public void InitializeComponent()
        {
            test = new System.Windows.Forms.TextBox();
            test.Location = new System.Drawing.Point(120, 8);
            test.Size = new System.Drawing.Size(232, 20);
            test.TabIndex = 0;
            Controls.AddRange(new System.Windows.Forms.Control[] { test });
            Size = new System.Drawing.Size(375, 150);
        }

        public void SetName(string text)
        {
            test.Text = text;
        }

        public string GetName()
        {
            return test.Text;
        }
    }
}

Ribbon1.cs:

using System;
using Microsoft.Office.Tools.Ribbon;

namespace ExcelAddIn1
{
    public partial class Ribbon1
    {
        private void toggleButton1_Click(object sender, RibbonControlEventArgs e)
        {
            Globals.ThisAddIn.TaskPane.Visible = ((RibbonToggleButton)sender).Checked;
        }

        private void button1_Click(object sender, RibbonControlEventArgs e)
        {
            button1.Label = Globals.ThisAddIn.MyContainer.GetName();
        }
    }
}

, , , .

, . "TabAddIn" , / . , . "test", , , , ?

, , . MSDN. , , ? , , - , , ... -.

+3

, (COM + Excel).

excel ( Excel → → )

enter image description here

.XLAM, . , .

+3

, Microsoft " : ". :

http://msdn.microsoft.com/en-us/library/bb608590.aspx

, , , , , , , . , , Microsoft - " "!

Analysis Toolpack, , .

, , , , , , , - , . , , , .

+2

, , @GaryP, , ( ), , , .

, :

, , , , ( , )...

SDI 2013 .

, .

+1

, , , , , XLAM ( , Excel), .

, , . addin , . , .

0

. , .

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);
}
0

, - , , , "Personal.xlsb". , , .

0

: , , .XLAM .. , . , , . :

  • → → → → " ..." .
  • → → → . Mange: Excel/Com, . Microsoft , . , , .
  • C:\Users\$USERNAME\AppData\Roaming\Microsoft\Excel\XLSTART .
  • C:\Users\$USERNAME\AppData\Roaming\Microsoft\AddIns .

. , , . , , , .

- , .

-1

Source: https://habr.com/ru/post/1547194/


All Articles