簡體   English   中英

使用超鏈接和文本創建 Powerpoint 形狀

[英]Create Powerpoint shape with hyperlink and text

我正在 powerpoint 中創建一個索引,其中包含指向其他幻燈片的鏈接,它可以很好地創建形狀和附加到形狀的超鏈接,但我無法讓它在形狀中添加文本。 目前,我在創建形狀后手動執行此操作。

我已經看到下面的方法,但在 TexttoDisplay 上出現錯誤。 我究竟做錯了什么? 如果我可以將超鏈接添加到框架而不是文本,那么我很樂意使用 TextFrames。

Sub CreateIndx()


' Create hyperlink to slide 2

Set pp = ActivePresentation


Set sh = pp.Slides(1).Shapes.AddShape(Type:=msoShapeRectangle, Left:=50, Top:=50, Width:=215, Height:=30)
With sh.ActionSettings(ppMouseClick)
.Action = ppActionHyperlink
.Hyperlink.Address = "..\War Memorial Slides\War Memorial Slides - Badlesmere to Elmley.pptx"
.Hyperlink.SubAddress = "1. Powerpoint Presentation"
        .TextToDisplay = "My Name"

End With

End Sub

更改文本:

Option Explicit
Sub CreateIndx()
    ' Create hyperlink to slide 2
    
    Dim pp
    Dim sh
    
    Set pp = ActivePresentation
    
    Set sh = pp.Slides(1).Shapes.AddShape(Type:=msoShapeRectangle, Left:=50, Top:=50, Width:=215, Height:=30)
    With sh.ActionSettings(ppMouseClick)
        .Action = ppActionHyperlink
        .Hyperlink.Address = "..\War Memorial Slides\War Memorial Slides - Badlesmere to Elmley.pptx"
        .Hyperlink.SubAddress = "1. Powerpoint Presentation"
    End With
    
    sh.TextFrame.TextRange.Text = "Test" '<<< Your text here

End Sub

如果您想要您創建的形狀中的文本,其他回復將為您解決問題。 相反,如果你想添加一個工具提示......當你將鼠標懸停在超鏈接形狀上時出現的小提示文本......使用這個:

Sub CreateIndx()
' Create hyperlink to slide 2

' I'm a believer in dimming all variables
' Saves time/trouble in the long run
Dim pp As Presentation
Dim sh As Shape

Set pp = ActivePresentation

Set sh = pp.Slides(1).Shapes.AddShape(Type:=msoShapeRectangle, Left:=50, Top:=50, Width:=215, Height:=30)
With sh.ActionSettings(ppMouseClick)
.Action = ppActionHyperlink
End With

With sh.ActionSettings(ppMouseClick).Hyperlink
    .Address = "..\War Memorial Slides\War Memorial Slides - Badlesmere to Elmley.pptx"
    .SubAddress = "1. PowerPoint Presentation"
    .ScreenTip = "My Name"
End With

End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM