SmartArt in presentations is used to provide the information in visual form. Sometimes, it is opted to make the simple text more appealing. Whereas, in other cases, it is used to demonstrate flow diagrams, processes, relationships between different entities, etc. In this article, you will learn how to create SmartArt in PowerPoint presentations programmatically in C#.

C# .NET API to Create SmartArt in PowerPoint PPT

To work with SmartArt in PowerPoint presentations, we will use Aspose.Slides for .NET. It is a powerful class library to create and manipulate PowerPoint and OpenOffice presentations. You can either install the API via NuGet or download its DLL.

PM> Install-Package Aspose.Slides.NET

Create a SmartArt Shape in PowerPoint PPT in C#

Aspose.Slides for .NET provides the easiest way to create the SmartArt shapes in the presentations. For demonstration, let’s create a SmartArt shape from scratch in a PowerPoint presentation using C#.

The following code sample shows how to create a SmartArt shape in a PowerPoint PPT in C#.

The following screenshot shows the output of the above code sample.

Create SmartArt in PowerPoint C#

Access a SmartArt Shape in PowerPoint using C#

You can also access the SmartArt shapes in the existing PowerPoint presentations. Once accessed, you can modify them as required. The following are the steps to access the SmartArt shapes in PowerPoint presentations using C#.

  • Create a new presentation or load an existing one using Presentation class.
  • Get reference of the desired slide into an ISlide object.
  • Loop through the shapes in the slide using ISlide.Shapes collection.
  • If the shape is of type ISmartArt, then get its reference into an ISmartArt object.
  • If required, filter the SmartArt shapes of a specific layout using ISmartArt.Layout property.

The following code sample shows how to access SmartArt shapes in PPT in C#.

Change SmartArt Shape’s Style in PowerPoint

Once you have accessed a SmartArt shape, you can change its style as well. The following steps demonstrate how to change the style of the SmartArt shapes in a PowerPoint PPT using C#.

The following code sample shows how to change the style of the SmartArt shapes in PowerPoint presentations.

C# PowerPoint API - Get a Free License

Get a free temporary license and work with PowerPoint SmartArt without evaluation limitations.

Conclusion

In this article, you have learned how to create SmartArt in PowerPoint presentations using C#. Moreover, you have seen how to access the SmartArt shapes and change their styles programmatically. You can explore the documentation to learn more about Aspose.Slides for .NET. In addition, you can ask your questions via our forum.

See Also