How to modify hyperlinks in PowerPoint documents in C#

Hyperlinks can easily guide the readers to the place you want to point to and it displays large amount of information to readers. Spire.Presentation for .NET enables developers to insert hyperlinks in PowerPoint presentations. Developers can also modify the existing hyperlinks and replace with new link text or target URL. This section will show how to edit hyperlinks from presentation slides in C#. Firstly check the screenshot of the original hyperlink:

Modify hyperlinks in PowerPoint documents

Spire.Presentation offers a ClickAction class for users to edit the hyperlinks. You can call the function ClickHyperlink to edit the hyperlinks. Here comes to the steps.

Step 1: Load a PowerPoint documents with hyperlinks.

Presentation pre = new Presentation();
pre.LoadFromFile(@"..\..\sample.pptx");

Step 2: Find the hyperlinks you want to edit.

IAutoShape shape = (IAutoShape)pre.Slides[0].Shapes[2];

Step 3: Edit the link text and the target URL.

shape.TextFrame.TextRange.ClickAction.Address = "http://www.e-iceblue.com";
shape.TextFrame.TextRange.Text = "E-iceblue";

Step 4: Save the document.

pre.SaveToFile(@"..\..\result.pptx",FileFormat.Pptx2010);

Effective screenshot after edit the hyperlink on presentation slide:

Modify hyperlinks in PowerPoint documents

Full codes:

namespace EditHyperlink
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation pre = new Presentation();
            pre.LoadFromFile(@"..\..\sample.pptx");
            IAutoShape shape = (IAutoShape)pre.Slides[0].Shapes[2];
            shape.TextFrame.TextRange.ClickAction.Address = "http://www.e-iceblue.com";
            shape.TextFrame.TextRange.Text = "E-iceblue";
            pre.SaveToFile(@"..\..\result.pptx",FileFormat.Pptx2010);
            System.Diagnostics.Process.Start(@"..\..\result.pptx");
        }
    }
}