Search code examples
c#visual-studio-2013add-invisual-studio-addinspowerpoint-2013

To fill shape with color in power point interop


I want to fill (255,168,0) color in my shape when I run this below code it kinda gives me a little lighter color in blue.

   private void Shape_fill_Click(object sender, RibbonControlEventArgs e)
    {
        Color_palette.Visible = true;
         type = "Fill";           
    }

    private void btn_Orange_Click(object sender, RibbonControlEventArgs e)
    {
        if(type=="Fill")
        { 
        PowerPoint.Application ppApp = Globals.ThisAddIn.Application;
        PowerPoint.ShapeRange ppshr = ppApp.ActiveWindow.Selection.ShapeRange;
        ppshr.Fill.ForeColor.RGB = System.Drawing.Color.FromArgb(255,168,0).ToArgb(); 
        }

Question: How can I get a different or a varying color other than lighter blue?


Solution

  • Here the color RGB is given in format of BGR because interop reads it as BGR and not RGB

    private void btn_Orange_Click(object sender, RibbonControlEventArgs e)
    {
        if(type=="Fill")
        {  
           PowerPoint.Application ppApp = Globals.ThisAddIn.Application;
                PowerPoint.ShapeRange ppshr = ppApp.ActiveWindow.Selection.ShapeRange;
                // here the color RGB is given in format of BGR because interop reads it as BGR and not RGB
    
                ppshr.Fill.ForeColor.RGB =System.Drawing.Color.FromArgb(0,168,255).ToArgb();
           }
     }