Set and Get Alternative Text (Title and Description) of PowerPoint Shapes in C#

With Spire.Presentation, we can programmatically set the Alternative Text for PowerPoint shapes along with get the Alternative Text of PowerPoint shapes. This article demonstrates how we can use Spire.Presentation to accomplish this function.

Detail steps:

Step 1: Instantiate a Presentation object and load the PowerPoint file.

Presentation ppt = new Presentation();
ppt.LoadFromFile("Input.pptx");

Step 2: Get the first slide.

ISlide slide = ppt.Slides[0];

Step 3: Set or get the alternative text of the first Shape in the slide.

//Set the alternative text (title and description)
slide.Shapes[0].AlternativeTitle = "Rectangle";
slide.Shapes[0].AlternativeText = "This is a Rectangle";

//Get the alternative text (title and description)
//string title = slide.Shapes[0].AlternativeTitle;
//string description = slide.Shapes[0].AlternativeText;

Step 4: Save the file.

ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013);

Screenshot after setting alternative text:

Set and Get Alternative Text 

(Title and Description) of PowerPoint Shapes in C#

Full code:

using Spire.Presentation;

namespace Set_and_Get_Alternative_Text_of_Shape
{
    class Program
    {
        static void Main(string[] args)
        {
            //Instantiate a Presentation object
            Presentation ppt = new Presentation();
            //Load the PowerPoint file
            ppt.LoadFromFile("Input.pptx");

            //Get the first slide
            ISlide slide = ppt.Slides[0];

            //Set the alternative text (title and description)
            slide.Shapes[0].AlternativeTitle = "Rectangle";
            slide.Shapes[0].AlternativeText = "This is a Rectangle";

            //Get the alternative text (title and description)
            //string title = slide.Shapes[0].AlternativeTitle;
            //string description = slide.Shapes[0].AlternativeText;

            //Save the file
            ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013);
        }
    }
}