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


Reply With Quote

