SmartArt is used to enhance the experience of PowerPoint presentations and to present data visually. It can be used to make the text more prominent and appealing and also be used to show flow diagrams, processes, relational charts, etc. In this article, you will learn how to create SmartArt in PowerPoint presentations using C++.
- C++ API for Creating SmartArt In PowerPoint Presentations
- Create a SmartArt Shape in PowerPoint using C++
- Access a SmartArt Shape in PowerPoint Presentation
- Change the Style of a SmartArt Shape using C++
C++ API for Creating SmartArt In PowerPoint Presentations
Aspose.Slides for C++ is a C++ API for working with PowerPoint files. It enables you to create, read and modify PPT and PPTX files without needing additional software. Furthermore, the API supports creating SmartArt in PowerPoint presentations. You can either install the API through NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.Slides.Cpp
Create a SmartArt Shape in PowerPoint using C++
The following are the steps to create a SmartArt shape in PowerPoint presentations.
- Create an instance of the Presentation class to represent a new PowerPoint file.
- Retrieve the desired slide.
- Add the SmartArt using the ISlide->get_Shapes()->AddSmartArt(float x, float y, float width, float height, SmartArt::SmartArtLayoutType layoutType) method.
- Save the presentation using the Presentation->Save(System::String fname, Export::SaveFormat format) method.
The following sample code shows how to create a SmartArt shape in PowerPoint using C++.
Access a SmartArt Shape in PowerPoint Presentation
You can access the SmartArt shapes in PowerPoint files by following the steps given below.
- Load the PowerPoint file using the Presentation class.
- Loop through the shapes.
- If the shape is of type ISmartArt, then get its reference as an ISmartArt object.
The following sample code shows how to access a SmartArt shape from a PowerPoint presentation using C++.
Change the Style of a SmartArt Shape using C++
You can easily change the style of the SmartArt shape after accessing it. The following are the steps to change the style of a SmartArt shape using C++.
- Load the PowerPoint file using the Presentation class.
- Loop through the shapes.
- If the shape is of type ISmartArt, then get its reference as an ISmartArt object.
- Change the style using the ISmartArt->set_ColorStyle(SmartArtColorType value) and ISmartArt->set_QuickStyle(SmartArtQuickStyleType value) methods.
- Save the presentation using the Presentation->Save(System::String fname, Export::SaveFormat format) method.
The following sample code shows how to change the style of a SmartArt shape using C++.
Get a Free License
In order to try the API without evaluation limitations, you can request a free temporary license.
Conclusion
In this article, you have learned how to create a SmartArt shape in PowerPoint presentations using C++. Furthermore, you have seen how to access and change the style of a SmartArt shape using Aspose.Slides for C++ API. It is a robust and feature-rich API that provides many additional features for working with PowerPoint files. You can explore the API in detail by visiting the official documentation. In case of any queries, please feel free to reach us at our free support forum.