I can't access the Object Members of any event I create! - am I missing something important?
Current example:
I am developing an Excel Office Add-In. I have an ExcelFile class to manage the file but I am trying to put the event method in the Ribbon class so that I can change the ribbon controls.
In a nutshell, this piece of the program needs to:
- Set my Custom Ribbon's Label Control text to the active sheet's name.
I have created a SheetActivate event for my C# Excel Office Add-In, using the following technique:
private event Excel.WorkbookEvents_SheetActivateEventHandler SheetActivateEvent;
...
public void Ribbon_Load(Office.IRibbonUI ribbonUI)
{
this.ribbon = ribbonUI;
ExcelFile TheFile = new ExcelFile();
SheetActivateEvent = new Excel.WorkbookEvents_SheetActivateEventHandler(SheetActivate);
TheFile.XLBook.SheetActivate += SheetActivateEvent;
}
...
private void SheetActivate(System.Object Sheet)
{
//WorkSheetLabel = Sheet.Name;
this.ribbon.Invalidate();
}
...
public String GetSheetLabel(Office.IRibbonControl Control)
{
return WorkSheetLabel;
}
The event works - if I place a breakpoint on the Ribbon Invalidate line I can clearly see the event is triggered every time I change the Active Sheet.
However I can't seem to access the Object's members. If I uncomment the Sheet.name code I receive errors, because there are no members in the Sheet object.
This problem occurs for my other events too.
How am I supposed to get the sheet name? Or do anything with the sheet, for that matter?
Hopefully I'm just being slow here...
Best Regards