none
Changing colours of charts in Excel RRS feed

  • Question

  • Hi,
    I am trying to create an addin where users can select a section of a graph, then click on a button which I will add to the ribbon and it will change its colour to one of the company's "standard" colours. However, I am having difficulty retrieving the section that the user has selected. This is the code that I am using:

                Chart co;
                Series s;
    
                co = ((Chart)Globals.ThisAddIn.Application.ActiveChart);
                s = ((Series)co.SeriesCollection(1));
    
                Microsoft.Office.Interop.Excel.Point p = ((Microsoft.Office.Interop.Excel.Point)s.Points(1));
                p.Interior.Color = 255;
    

    I have found the "SeriesChanged" event which can retrieve the currently selected Point, but it needs to be hooked up to each individual chart, and I can't work out how to do this. I need to be able to do it for both new and existing charts.

    Many thanks
    Thursday, June 11, 2009 4:08 PM

Answers

  • Not to worry, I worked it out :
                    Microsoft.Office.Interop.Excel.Point p = ((Microsoft.Office.Interop.Excel.Point)Globals.ThisAddIn.Application.Selection);
                    p.Interior.Color = 255;
    

    Friday, June 12, 2009 9:04 AM