Add multiple hyperlinks in Powerpoint (automation)

L

lorraine

I'm having issues with adding hyperlinks to specific words within a
TextRange.

Through vbscript automation, I'm generating a powerpoint package of
various slides. One of my slides is Table of Contents with a bullet
listing of the title of every slide in single textbox shape. I want
each title to hyperlink to the slide itself.

It's possible in Powerpoint to simply highlight a line of text and add
a hyperlink to it, but when I try to mimic that in automation by using
the Find("<text to search>") method to return a TextRange and add a
hyperlink to that, I'm only allowed one hyperlink for the overall shape
object. aka each time I add a hyperlink to a new TextRange returned by
Find, it deletes the old one before it adds the new one.

I was hoping that .Find would do the trick and allow me to add multiple
hyperlinks without having to add a new shape for each slide I want to
link to.

Is there anyway of having multiple hyperlinks on a slide without adding
a new textbox shape for each? Or is it more of a question of changing
the maximum number of hyperlinks per shape?

Thanks
Lorraine
 
S

Steve Rindsberg

Lorraine said:
I'm having issues with adding hyperlinks to specific words within a
TextRange.

Through vbscript automation, I'm generating a powerpoint package of
various slides. One of my slides is Table of Contents with a bullet
listing of the title of every slide in single textbox shape. I want
each title to hyperlink to the slide itself.

It's possible in Powerpoint to simply highlight a line of text and add
a hyperlink to it, but when I try to mimic that in automation by using
the Find("<text to search>") method to return a TextRange and add a
hyperlink to that, I'm only allowed one hyperlink for the overall shape
object. aka each time I add a hyperlink to a new TextRange returned by
Find, it deletes the old one before it adds the new one.

This seems not to:

Sub TextHyperlinks()

Dim oRng As TextRange
Dim x As Long
Dim oSh As Shape

Set oSh = ActiveWindow.Selection.ShapeRange(1)

Set oRng = oSh.TextFrame.TextRange.Find(FindWhat:="This")
If Not (oRng Is Nothing) Then
With oRng.ActionSettings(ppMouseClick).Hyperlink
.Address = "Hah! Found ya, ya little weevil!"
End With
End If

Set oRng = oSh.TextFrame.TextRange.Find(FindWhat:="That")
If Not (oRng Is Nothing) Then
With oRng.ActionSettings(ppMouseClick).Hyperlink
.Address = "Did this erase the last one?"
End With
End If

End Sub
I was hoping that .Find would do the trick and allow me to add multiple
hyperlinks without having to add a new shape for each slide I want to
link to.

Is there anyway of having multiple hyperlinks on a slide without adding
a new textbox shape for each? Or is it more of a question of changing
the maximum number of hyperlinks per shape?

Each character in a text box can have a different hyperlink applied to it if
you like. Bear in mind that the text and the shape that contains it can both
have hyperlinks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top