1

I'm following up to two questions (Here & Here) that were asked regarding this issue of using VBA to grab a hyperlink from Excel and insert it into PowerPoint.

Below is the code I have - I've tried tweaking with it but I can't get it to place the hyperlink into the cell and display text as it never gets past this point:

.Address = getAddress

The code breaks with this error message: "Run-time error '438': Object doesn't support this property or method."

I apologize if this is a rehash. Any help would be appreciated.

Option Explicit
Sub PPTableMacro()

    Dim oPPTApp As PowerPoint.Application
    Dim oPPTShape As PowerPoint.Shape
    Dim oPPTFile As PowerPoint.Presentation
    Dim SlideNum As Integer  
    Dim strPresPath As String
    Dim strExcelFilePath As String
    Dim getAddress As Hyperlink

    strPresPath = "C:\Somewhere...\Presentation.pptm"

    Set oPPTApp = CreateObject("PowerPoint.Application")
    oPPTApp.Visible = msoTrue

    Set oPPTFile = oPPTApp.Presentations.Open(strPresPath)
    SlideNum = 4
    oPPTFile.Slides(SlideNum).Select

    Set oPPTShape = oPPTFile.Slides(SlideNum).Shapes("Table 1")

    Sheets("Sheet1").Activate

    Set getAddress = Sheet1.Range("F1").Hyperlinks(1)

    oPPTShape.Table.Cell(1, 2).Shape.TextFrame.TextRange.Text = Cells(1, 1)
    oPPTShape.Table.Cell(2, 2).Shape.TextFrame.TextRange.Text = Cells(1, 2)
    oPPTShape.Table.Cell(3, 2).Shape.TextFrame.TextRange.Text = Cells(1, 3)
    oPPTShape.Table.Cell(4, 2).Shape.TextFrame.TextRange.Text = Cells(1, 4)
    oPPTShape.Table.Cell(5, 2).Shape.TextFrame.TextRange.Text = Cells(1, 5)
    With oPPTShape.Table.Cell(6, 2).Shape.TextFrame.TextRange.ActionSettings(ppMouseClick).Hyperlink
        .Address = getAddress.Address
        .TextToDisplay = "Link"
    End With

    Set oPPTShape = Nothing
    Set oPPTFile = Nothing
    Set oPPTApp = Nothing

End Sub

Edit: So I've been searching the web for anyone else who's come across this issue but so far I haven't had any luck. There's nothing else on stack overflow I could find to help, nor did I find anything on the Microsoft Developer site for Office 2010. I looked at the examples provided there for the Hyperlink.TextToDisplay ="..." attribute and it looks like I'm doing everything right. I hope its not a cheap shot to edit my question in hopes someone will see it, but I'm not sure what else to do on this one.

Community
  • 1
  • 1
ckemmann
  • 101
  • 1
  • 1
  • 8
  • 1
    Try '.Address = getAddress.Address' on the line that's giving you an error. The object 'getAddress' isn't a path it is a Hyperlink Object. The PPT Hyperlink.Address field expects a String, not a Hyperlink Object. – Kris B Nov 06 '15 at 21:33
  • @KrisB - I tried that as you suggested, but then it stops on the next line of code `.TextToDisplay = "Link"` and gives me the following error message: "Hyperlink (unknown member) : Invalid request. This kind of object cannot have hyperlink associated with it." Any thoughts? – ckemmann Nov 09 '15 at 12:07

0 Answers0