Search code examples
office365powerpointoffice-interopoffice-addinspowerpoint-2016

How to apply Gradient to Line/Border of a shape in Powerpoint using C#?


In PowerPoint 2016 UI, it is possible to apply a gradient to the Border of a shape. The same however cannot be done using Microsoft.Office.Interop.PowerPoint in C#. I was able to apply a gradient to the shape but not to its border. Kindly advise how can it be achieved.


Solution

  • I agree: there is no way that I can see to set a line gradient via the Interop assemblies. The clue for me was that you can't use the simple controls on the ribbon to do this, you need to use "Format Shape", and then you can set a bunch of stuff that also isn't available. This led me to think it was in the XML of the file, not accessible via the Object Model (OM) that the interop library provides.

    I would recommend using a tool that can interact with the XML of the file itself, not just the application. It may also benefit you that you won't need to actually run PowerPoint, just edit the file. That can be faster.

    Example tools are the Open XML SDK and something like Aspose.Slides, both of which edit the files directly.

    MS-provided Interop libraries are dying. They've stopped distributing signed copies for the most recent versions, instead letting developers generate and sign their own. Office add-ins are the new thing right now, as they are cross-platform.

    I hope this helps. Good luck.