Answer 1
There are two different type Buttons
Oleobjects Forms
Since oleobjects aren't suppose to be used in new designs I will on use the Forms button. the capture of the forms button can be assigned to any macro. To assign the button to the macro use htis code
This is VBA.
Set myBut = Sheets("Sheet1").Buttons.Add(332.25, 130.5, 6, 6)
myBut.OnAction = "Macro1"
Rather than add buttons and macros to your Visual Studio code you may want to create a template Excel Workbook and use the template to create you new excel workbook rather than start from scratch.
You would need to add a macro into the excel workbook. To add a macro into an excel workbook you need to create a "*.BAS" Text file and import the text file into the workbook. The best way of creating the BAS file is to create a macro manually
into a workbook and then export the file.
I would look at Chip Pearson's Webiste on the code to exporting and import the BAS file. See webpage. Chips code is in VBA ode but can easily be converted to C++, C#, VBnet. Make sure you add the reference below (even in C# or C++ becauwe
you are adding a VBA macro to the workbook)
Microsoft Visual Basic For Applications Extensibility 5.3.
http://www.cpearson.com/Excel/vbe.aspx