views:

30

answers:

1

Hi,

I have this problem, I use :

//someWord is a TextRange object from PPT TextBox
String address = someWord.ActionSettings[PpMouseActivation.ppMouseClick].Hyperlink.Address;

I'm sure that this is the way to read address to webpages in a link, I was using this in PPT 2003, and it works! BUT, now I'm trying to do the same in PPT 2007 and the .Hyperlink.Address is always equal to null.

Any suggestion? thank you!

A: 

It's possible that the URL is couched in a set of runs. Like if you had a text box that looked like this:

A search engine: Ask Jeeves

It technically has two runs. Try both of these in VBA and see if one or both (or none) work:

Sub getHyperlinkfromTextRun()
    Dim sl As Slide: Set sl = ActivePresentation.Slides(2)
    Dim sh As Shape: Set sh = sl.Shapes(1)
    Dim tr As TextRange: Set tr = sh.TextFrame.TextRange
    Dim URL As String
    For i = 1 To tr.Runs.Count
        URL = tr.Runs(i).ActionSettings(ppMouseClick).Hyperlink.Address
        If Len(URL) > 0 Then
            Dim runText As String
            runText = tr.Runs(i).Text
            Debug.Print "RUN " & i & ": " & runText & ", " & "URL: " & URL
        End If
    Next
End Sub

Sub getHyperlinkfromTextRange()
    Dim sl As Slide: Set sl = ActivePresentation.Slides(2)
    Dim sh As Shape: Set sh = sl.Shapes(1)
    Dim tr As TextRange: Set tr = sh.TextFrame.TextRange
    Debug.Print tr.ActionSettings(ppMouseClick).Hyperlink.Address
End Sub
Otaku