Adding a button to a worksheet

Jun 18, 2015 at 9:17 PM
Hi all,

I'm new to using Excel DNA and I am currently working on my second Add-in for excel. I'm self taught for the most part on C#, C++, VBA, SQL. I'm fluent but I'm just not an expert yet. just keep that in mind when replying and I'd appreciate it.

I need to know what is the simplest way to add a button to a worksheet using Excel-DNA and C#. Of course I'd also like to be able to use the events from the button being clicked.

I have looked a few examples here and they seem so long and convoluted I was wondering if there was a simpler, quicker way. Also if you could refer to some documentation where I can read up on this, I'd really appreciate it.

I'm trying to create an automated workbook that can create a few charts/tables by selecting a few parameters (via Combobox or alike) and then pushing a button to initiate the method to create the chart/tables (on a new sheet). This is something I have already made using VBA but would like to redo using C#.

Second Question
What is the best method for including a template Excel Workbook inside the .xll file? Right now, I've added the template.xlsx file as an embedded resource. On the AutoOpen() method the file is read via stream then written into the same directory as the .xll file, then opened.
Jun 19, 2015 at 9:51 AM
Can't you just add a button to the ribbon, to run your charting macro?
That would be simplest.

Otherwise you'd have to use the COM object model to add a button to the sheet. I don't have a sample of that at hand, though.

Your embedded resource plan for the templates sounds good.