Custom Task Panes in 0.29

271 views
Skip to first unread message

PaulUK

unread,
May 30, 2011, 6:45:44 AM5/30/11
to Excel-DNA
Hi,
I am using ExcelDna version 0.29, all installed and working okay.
In the distribution samples is a file called CustomTaskPane.dna that I
have imported into a c# project so that all but the xml definition of
the task pane is included in a single cs file. My question is what do
I do with the XML component and how can I assign the XML to the
CustomTaskPane control?
Thanks,
Paul.
P.S. ExcelDna is a great piece of software - thanks Govert for sharing
it.

Govert van Drimmelen

unread,
May 30, 2011, 8:22:29 AM5/30/11
to Excel-DNA
Hi Paul,

The <CustomUI> xml part in that example (and its corresponding
MyRibbon class) just define a ribbon tab with some buttons to show and
hide the Custom Task Pane. So the xml is not really part of the CTP
story itself.

The CustomTaskPane is defined by whatever UserControl-derived class
you use - in that case MyUserControl. From Visual Studio you could
also make a new UserControl and use the designer to populate it. To
display it you call CustomTaskPaneFactory.CreateCustomTaskPane(...)
which in this case is called via a ribbon button handler. You could
also call this from a macro fired from a CommandBar button, the Alt+F8
dialog, or some event.

To make a ribbon, you can either have the <customUI> xml stuff in
the .dna file, or you can return the xml content string from a
GetCustomUI override in your ExcelRibbon-derived class. This string
can be extracted from resources, or built on the fly if need be.

Please write back if I need to clarify or expand more.

Regards,
Govert

Paul Beeston

unread,
May 30, 2011, 11:26:22 AM5/30/11
to exce...@googlegroups.com
Thanks Govert - that worked for me.


--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To post to this group, send email to exce...@googlegroups.com.
To unsubscribe from this group, send email to exceldna+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/exceldna?hl=en.


Fr8Partner A/S

unread,
Nov 22, 2017, 7:32:51 AM11/22/17
to Excel-DNA
Hi Govert.

You write

...

The CustomTaskPane is defined by whatever UserControl-derived class
you use - in that case MyUserControl. From Visual Studio you could
also make a new UserControl and use the designer to populate it. To
display it you call CustomTaskPaneFactory.CreateCustomTaskPane(...)
which in this case is called via a ribbon button handler.
...

When i insert my own designet UserControl (Add > New item... > Custom Control)  and run Excel it gives an Exception:

System.Runtime.InteropServices.COMException: 'ActiveX component can't create object'

Implementation:
ctp = CustomTaskPaneFactory.CreateCustomTaskPane(typeof(UserControl2), "VS designed Task Pane");

I have not made any manuel changes til the definition of UserControl2


namespace Fr8BenchRibbon
{
   
public partial class UserControl2
   
{
       
/// <summary>
       
/// Required designer variable.
       
/// </summary>
       
private System.ComponentModel.IContainer components = null;

       
/// <summary>
       
/// Clean up any resources being used.
       
/// </summary>
       
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
       
protected override void Dispose(bool disposing)
       
{
           
if (disposing && (components != null))
           
{
                components
.Dispose();
           
}
           
base.Dispose(disposing);
       
}

       
#region Component Designer generated code

       
/// <summary>
       
/// Required method for Designer support - do not modify
       
/// the contents of this method with the code editor.
       
/// </summary>
       
private void InitializeComponent()
       
{
           
this.checkedListBox1 = new System.Windows.Forms.CheckedListBox();
           
this.label1 = new System.Windows.Forms.Label();
           
this.SuspendLayout();
           
//
           
// checkedListBox1
           
//
           
this.checkedListBox1.FormattingEnabled = true;
           
this.checkedListBox1.Location = new System.Drawing.Point(56, 162);
           
this.checkedListBox1.Name = "checkedListBox1";
           
this.checkedListBox1.Size = new System.Drawing.Size(120, 94);
           
this.checkedListBox1.TabIndex = 0;
           
//
           
// label1
           
//
           
this.label1.AutoSize = true;
           
this.label1.Location = new System.Drawing.Point(70, 94);
           
this.label1.Name = "label1";
           
this.label1.Size = new System.Drawing.Size(35, 13);
           
this.label1.TabIndex = 1;
           
this.label1.Text = "label1";
           
//
           
// UserControl2
           
//
           
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
           
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
           
this.Controls.Add(this.label1);
           
this.Controls.Add(this.checkedListBox1);
           
this.Name = "UserControl2";
           
this.Size = new System.Drawing.Size(293, 367);
           
this.ResumeLayout(false);
           
this.PerformLayout();

       
}

       
#endregion

       
private System.Windows.Forms.CheckedListBox checkedListBox1;
       
private System.Windows.Forms.Label label1;
   
}
}

Can you please guide me in the right direction, så that i can use the visuel design of the CTP?


Reply all
Reply to author
Forward
0 new messages