I've been told to write up an Excel-Add-In which pastes a specific footer into every worksheet in a workbook.
After reading up the documentation of the Excel.Interop namespace I ended up with this junky piece of code:
public partial class Ribbon1
{
Excel.Application _excelApp;
private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
{
_excelApp = new Excel.Application();
}
private void button1_Click(object sender, RibbonControlEventArgs e)
{
var filename = _excelApp.GetSaveAsFilename();
Excel._Worksheet worksheet = (Excel._Worksheet)_excelApp.ActiveSheet;
worksheet.PageSetup.CenterFooter = filename;
}
}
I have a problem in pinning the active worksheet. How can I actually use this object? - Right now it is null. I find the msdn articles related to this topic just plain stupid.