Using VSTO or some related technology, is it possible to programmatically embed a button in a cell of an Excel worksheet, and configure it to call a C# function when it is clicked?
How?
Thanks.
Using VSTO or some related technology, is it possible to programmatically embed a button in a cell of an Excel worksheet, and configure it to call a C# function when it is clicked?
How?
Thanks.
With a VSTO document customization (i.e., a Workbook with .Net code attached), you can add and remove controls at runtime to the Worksheets of the project. The following code illustrates the idea:
You could also add controls dynamically to documents via a VSTO add-in, using code along these lines (thanks to people on the VSTO forum for that one):
Check this post by Eric Carter for more info.
Here is the code which works for me in VSTO Add-in (modified version of Mathias's answer):