Creating a UI with Excel DNA

449 views
Skip to first unread message

Hristo Hristov

unread,
Feb 3, 2015, 5:16:17 AM2/3/15
to exce...@googlegroups.com
Hi everyone, I have an add-in built with VSTO and I would like to port it's UI interface to my Excel-DNA. How do I start? I didn't quite manage to find a tutorial online on how to create an UI with Excel-DNA.

Hristo Hristov

unread,
Feb 3, 2015, 7:05:57 AM2/3/15
to exce...@googlegroups.com
Here's what I know for now : 

Since I want to add a custom task pane to my application I had to put the ComVisible attribute on the control which will get inserted inside the task pane.

    internal class ThisAddIn : IExcelAddIn
    {
        public void AutoOpen()
        {
            var app = ExcelDnaUtil.Application as Microsoft.Office.Interop.Excel.Application;
            try
            {
                app.WorkbookOpen += app_WorkbookOpen;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        void app_WorkbookOpen(Workbook Wb)
        {
            CustomTaskPane ctp = CustomTaskPaneFactory.CreateCustomTaskPane(typeof(DrawingControlLib.DrawingControl), "Drawer");
            ctp.DockPosition = MsoCTPDockPosition.msoCTPDockPositionRight;
            ctp.Width = 400;
            ctp.Visible = true;
        }
        public void AutoClose() { }
    }

But I cannot enter in any way inside the Workbook open event, so what is going on there? How does this work, please help ! :)

Govert van Drimmelen

unread,
Feb 3, 2015, 7:39:55 AM2/3/15
to exce...@googlegroups.com

Your ThisAddIn class must be public, else it won’t run at all.

 

-Govert

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at http://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

Hristo Hristov

unread,
Feb 3, 2015, 8:32:27 AM2/3/15
to exce...@googlegroups.com
It seems that I get teh same behaviour in both ways : either public or private, the event doesn't fire whenever I open a workbook , altho it seems that the task pane starts whenever the application opens and then it closes.

Hristo Hristov

unread,
Feb 3, 2015, 8:36:06 AM2/3/15
to exce...@googlegroups.com
I should probably also add that I'm using a WPF control inside an Element Host for my control.


вторник, 3 февруари 2015 г., 12:16:17 UTC+2, Hristo Hristov написа:
Reply all
Reply to author
Forward
0 new messages