How to Insert a hyperlink in Powerpoint 2007
How to Insert a hyperlink in Powerpoint 2007
So you think you know how to insert a hyperlink? Well, think again. Microsoft has changed the internal code of Powerpoint 12. The old way of inserting hyperlinks won't work anymore.
Here was my delimma. I needed to be able to programmatically insert a hyperlink into a slide when the user clicked my ribbon (menu) item. My old code looked like this
VB Code:
Sub test1()
With Application.ActiveWindow.Selection.TextRange.ActionSettings _
(ppMouseClick).Hyperlink
.Address = "C:\Documents and Settings\chris.dunsford\My Documents\test.doc"
.SubAddress = ""
.ScreenTip = ""
.TextToDisplay = "test"
End With
End Sub
So then I try running the code from Powerpoint help and the hyperlink seems to be inserted but no text will appear. Here is the code from Powerpoint help:
VB Code:
With ActivePresentation.Slides(1).Shapes(1) _
.ActionSettings(ppMouseClick)
.Action = ppActionHyperlink
.Hyperlink.Address = "http://www.microsoft.com/"
End With
The code that finally works is:
VB Code:
Sub AddHyperlinkToSelection()
Dim tr As TextRange
Set tr = ActiveWindow.Selection.TextRange.InsertAfter("Hyperlink")
tr.ActionSettings(ppMouseClick).Action = ppActionHyperlink
tr.ActionSettings(ppMouseClick).Hyperlink.Address = "c:\test.doc"
End Sub
Re: How to Insert a hyperlink in Powerpoint 2007
Welcome to the Forums.
Did you see from the help file that it wont be supported on a graphic?
Quote:
Returns or sets the display text for a hyperlink not associated with a graphic.
Did you want to submit this as an Office Development FAQ?
Re: How to Insert a hyperlink in Powerpoint 2007
I skipped over that :)
I do think that this should be listed in the FAQ section. I was contemplating that when I posted it.