使用VBA在PowerPoint表格单元格中插入超链接 [英] Insert hyperlink in a PowerPoint table cell with VBA

查看:496
本文介绍了使用VBA在PowerPoint表格单元格中插入超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PowerPoint2007.我想使用列表在幻灯片上创建表格.每行的第一列将具有指向演示文稿中另一张幻灯片的超链接(如摘要幻灯片).

I'm working with PowerPoint 2007. I want to use a list to create a table on a slide. The first column of each row will have a hyperlink to a different slide in the presentation (like a summary slide).

我在使用VBA将超链接插入单元格时遇到麻烦.错误消息通常类似于对象不支持该功能".

I'm having trouble using VBA to insert a hyperlink into a cell. The error message is usually something like "object doesn't support that function".

这是违规行:

With pptPres.Slides(2).Shapes("Table Summary").Table.Cell(i - 1, 1).Shape.ActionSettings(ppMouseClick).Hyperlink
    .TextToDisplay = ThisWorkbook.Sheets(i).Range("B1")
    .SubAddress = pptPres.Slides(i).SlideID
End With

推荐答案

您快到了.
您需要访问 TextRange对象 ,如果您想在表格或形状内的文本中添加 Link .
像这样:

You're almost there.
You need to access TextRange Object if you want to add a Link in the text within a table or shape.
Something like:

Sub marine()
    Dim t As Table
    Dim pptpres As Presentation

    Set pptpres = ActivePresentation
    Set t = pptpres.Slides(1).Shapes(1).Table

    With t.Cell(2, 1).Shape.TextFrame.TextRange.ActionSettings(ppMouseClick).Hyperlink
        .TextToDisplay = "Link to Slide"
        .SubAddress = pptpres.Slides(2).SlideNumber _
            & ". " & pptpres.Slides(2).Name
    End With
End Sub

而且,您不能将 SlideID 属性用作 SubAddress .
它应采用以下格式:<slide number><dot><space><slide name>(例如#2.Slide2)
为此,我们使用了 SlideNumber Name 属性. HTH

And also, you cannot use SlideID property as SubAddress.
It should be in this format: <slide number><dot><space><slide name> (eg. #2. Slide2)
To get this done we used SlideNumber and Name property instead. HTH

这篇关于使用VBA在PowerPoint表格单元格中插入超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆