0

We have a couple of spreadsheets here that we populate with some data and do some formatting using Microsoft.Office.Interop.Excel.

Now that part is all good - it's something along the lines of what is done here: Write to Excel example.

What I'd like to do is:

  • Add a button inside the spreadsheet, bound to a macro.
  • When the user clicks the button, the macro fires - we grab some parameters from the cells and pass those to the C# function. That code does all the heavy lifting, populates the spreadsheet as above, etc.

What I don't understand how to do is that second step - I can't see a way to actually pass parameters and call into C# directly. As it stands now, I can call a C# console application and pass command line parameters into it... but that seems a bit wrong, I'd have thought there would be some better way - but I can't seem to find it!

shA.t
  • 16,580
  • 5
  • 54
  • 111
Coopernick
  • 229
  • 2
  • 17

1 Answers1

1

Coopernick,

It looks like you need to develop an Excel add-in and move the VBA code on the add-in rails. See Walkthrough: Creating Your First Application-Level Add-in for Excel to get started quickly. You may consider an Excel add-in as a regular .Net application where you can use any components and libraries.

You may find the Excel Solutions section in MSDN helpful.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45