如何使用Interop向幻灯片添加超链接

时间:2013-01-17 16:22:28

标签: hyperlink interop powerpoint

如何使用c#在演示文稿中添加超级链接到具体幻灯片? 目前我已经找到了如何超链接到网站:

TextRange.ActionSettings [Microsoft.Office.Interop.PowerPoint.PpMouseActivation.ppMouseClick] .Hyperlink.Address =“http://www.google.com”;

找到了Last / First / Next

的选项

TextFrame.TextRange.ActionSettings [PpMouseActivation.ppMouseClick] .Action = PpActionType.ppActionFirstSlide;

但不是slide4

1 个答案:

答案 0 :(得分:1)

如果您在PowerPoint中手动添加设置,请询问设置是什么,它会告诉您。例如,将幻灯片4的链接添加到文本框,确保选中该文本框并运行:

Sub Thing()
    Dim oSh As Shape
    Set oSh = ActiveWindow.Selection.ShapeRange(1)
    With oSh
        Debug.Print .ActionSettings(1).Hyperlink.Address
        Debug.Print .ActionSettings(1).Hyperlink.SubAddress
    End With
End Sub

结果,空白行(没有超链接地址)和子地址​​:

259,4,Title of slide 4

259是SlideID 4是SlideIndex “幻灯片4的标题”是幻灯片4上的标题文本

我很确定ID和索引是必要的;标题不是。例如,在同一演示文稿中设置幻灯片3的链接:

Sub ThingTwo()
    Dim oSh As Shape
    Set oSh = ActiveWindow.Selection.ShapeRange(1)
    With oSh
        .ActionSettings(1).Hyperlink.Address = ""
        .ActionSettings(1).Hyperlink.SubAddress = "258,3,"
    End With
End Sub

在c#中做这个...留给读者练习。