如何在C#,VB.NET中链接到PowerPoint中的特定幻灯片

PowerPoint文件中的超链接不仅可以链接到外部URL,还可以链接到文档中的特定幻灯片。本文将展示如何使用Spire.Presentation创建链接到指定幻灯片的超链接。

下载Spire.Presentation最新版本

第1步:创建一个PowerPoint文件并附加幻灯片。

Presentation presentation=New presentation();
presentation.Slides.Append();

第2步:向第二张幻灯片添加形状。

AutoShape shape = presentation.Slides [1] .Shapes.AppendShape(ShapeType.Rectangle,new RectangleF(10,50,200,50));
shape.TextFrame.Text =“跳转到第一张幻灯片”; 

第3步:根据形状和文本创建超链接,链接到第一张幻灯片。

ClickHyperlink hyperlink = new ClickHyperlink(presentation.Slides [0]);
shape.Click = hyperlink;
shape.TextFrame.TextRange.ClickAction = hyperlink;

第4步:保存文件。

presentation.SaveToFile(“hyperlink.pptx”,FileFormat.Pptx2010);

输出

linktosper

完整代码

[C#]

Presentation presentation=New presentation();
presentation.Slides.Append();
AutoShape shape = presentation.Slides [1] .Shapes.AppendShape(ShapeType.Rectangle,new RectangleF(10,50,200,50));
shape.TextFrame.Text =“跳转到第一张幻灯片”; 
ClickHyperlink hyperlink = new ClickHyperlink(presentation.Slides [0]);
shape.Click = hyperlink;
shape.TextFrame.TextRange.ClickAction = hyperlink;
presentation.SaveToFile(“hyperlink.pptx”,FileFormat.Pptx2010);

[VB.NET]

Dim presentation As Presentation = New Presentation();
presentation.Slides.Append();
Dim shape As IAutoShape = presentation.Slides(1).Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(10, 50, 200, 50));
shape.Fill.FillType = FillFormatType.None;
shape.Line.FillType = FillFormatType.None;
shape.TextFrame.Text = "Jump to the first slide";
Dim hyperlink As ClickHyperlink = New ClickHyperlink(presentation.Slides(0));
shape.Click = hyperlink;
shape.TextFrame.TextRange.ClickAction = hyperlink;
presentation.SaveToFile("output.pptx", FileFormat.Pptx2010);

猜你喜欢

转载自blog.csdn.net/xiaochuachua/article/details/81114723