none
How to change fill type to gradient for shape in PowerPoint using c#? RRS feed

  • Question

  • Hi

    I have created a shape in powerPoint using c#.

    I am not able to change the fill type to gradient for the same.

    Regards,

    Akash.

    Monday, April 16, 2012 8:18 AM

Answers

  • You can try something like below.  I used a converter from VB.Net to C# so I can't attest to the conversion accuracy.

    public void WorkWithShape()
    {
    	PowerPoint.Presentation ppt = Globals.ThisAddIn.Application;
    	ppt.Slides(3).Shapes(1).Name = "My Name";
    	ppt.Slides(3).Shapes(1).Fill.PresetGradient(Office.MsoGradientStyle.msoGradientVertical, 1, Office.MsoPresetGradientType.msoGradientBrass);
    }


    Kind Regards, Rich ... http://greatcirclelearning.com

    • Marked as answer by AkashKale Tuesday, April 17, 2012 7:26 AM
    Monday, April 16, 2012 8:01 PM
  • Thanks Rich,
    It works, I also tried this one

    rectangle.Fill.OneColorGradient(Microsoft.Office.Core.MsoGradientStyle.msoGradientHorizontal, 1, 0.1f);

    Regards,
    Akash

    • Marked as answer by AkashKale Tuesday, April 17, 2012 7:26 AM
    Tuesday, April 17, 2012 7:26 AM

All replies

  • You can try something like below.  I used a converter from VB.Net to C# so I can't attest to the conversion accuracy.

    public void WorkWithShape()
    {
    	PowerPoint.Presentation ppt = Globals.ThisAddIn.Application;
    	ppt.Slides(3).Shapes(1).Name = "My Name";
    	ppt.Slides(3).Shapes(1).Fill.PresetGradient(Office.MsoGradientStyle.msoGradientVertical, 1, Office.MsoPresetGradientType.msoGradientBrass);
    }


    Kind Regards, Rich ... http://greatcirclelearning.com

    • Marked as answer by AkashKale Tuesday, April 17, 2012 7:26 AM
    Monday, April 16, 2012 8:01 PM
  • Thanks Rich,
    It works, I also tried this one

    rectangle.Fill.OneColorGradient(Microsoft.Office.Core.MsoGradientStyle.msoGradientHorizontal, 1, 0.1f);

    Regards,
    Akash

    • Marked as answer by AkashKale Tuesday, April 17, 2012 7:26 AM
    Tuesday, April 17, 2012 7:26 AM