Avatar of scandinfo

asked on 

Interop Excel C#: Check if ChartObject is selected

I have made a custom Ribbon menu that sets our company formatting to charts. As the code works now it makes the same formatting for each chart object on one sheet. But now I need to format just one chart if it's selected.

The question is. How do I check if a chart object is selected and get a hold of it?

This is the code I'm using now:
private void SetColorHandler(object sender, RibbonControlEventArgs e)
                Excel.Workbook excelWorkBook = Globals.ThisAddIn.Application.ActiveWorkbook;
                Excel.Worksheet activeWorksheet = excelWorkBook.ActiveSheet;

                foreach (Excel.ChartObject chartObj in activeWorksheet.ChartObjects())
                              //Do something

Open in new window

C#.NET ProgrammingMicrosoft Excel

Avatar of undefined
Last Comment

8/22/2022 - Mon