Results 1 to 8 of 8

Thread: Hyperlinking to Embedded Object

  1. #1
    VBAX Expert
    Joined
    Feb 2005
    Posts
    924
    Location

    Hyperlinking to Embedded Object

    Assume a Word doc, say, "A.Doc", has been inserted (as an object) into a spreadsheet on tab "B". It is easy to open the object by double clicking on the Icon, but is there a way to hyperlink to the embedded object?

    Thanks
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  2. #2
    VBAX Contributor samohtwerdna's Avatar
    Joined
    Dec 2004
    Location
    Denver Colorado
    Posts
    143
    Location
    I'm a little confused about what your asking here - but very interested.

    Would you like to create a hyperlink that navigates to a new worksheet where an embedded object (A.DOC) is ? Or would this also work inside the worksheet that has the object?

    I have a similar desire to use hyperlinks to embed objects into a spreadsheet on a temp sheet. So I would love to hear what answers you get.

    Is there any way to get a click event on text in a cell without using Hyperlink?
    Maybe that would solve our problems
    To live is Christ... To code is cool!

  3. #3
    VBAX Expert
    Joined
    Feb 2005
    Posts
    924
    Location
    Quote Originally Posted by samohtwerdna
    I'm a little confused about what your asking here - but very interested.

    Would you like to create a hyperlink that navigates to a new worksheet where an embedded object (A.DOC) is ? Or would this also work inside the worksheet that has the object?

    I have a similar desire to use hyperlinks to embed objects into a spreadsheet on a temp sheet. So I would love to hear what answers you get.

    Is there any way to get a click event on text in a cell without using Hyperlink?
    Maybe that would solve our problems
    I primary need is to create a hyperlink from inside the workbook that leads to the inserted object and opens it. There are several workarounds, e.g., A.Doc initially resided outside the workbook; creating a hyperlink to it (manually of with VBA) was trivial. But that means that the "location" of A.Doc must remain consistent relative to the workbook -- not impossible, but a pain. If A.Doc is inside the workbook, all concerns about location and version management disappear. Directly clicking on the object is another workaround, but that is clumsy.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  4. #4
    VBAX Contributor samohtwerdna's Avatar
    Joined
    Dec 2004
    Location
    Denver Colorado
    Posts
    143
    Location
    MMM - I agree.

    Still a little fuzzy - Do you care if the A.Doc is open in Word or embeded into Excel?

    I assume that you are looking for something that will work with any embeded object's not just Word Doc's...right?
    To live is Christ... To code is cool!

  5. #5
    VBAX Expert
    Joined
    Feb 2005
    Posts
    924
    Location
    Quote Originally Posted by samohtwerdna
    MMM - I agree.

    Still a little fuzzy - Do you care if the A.Doc is open in Word or embeded into Excel?

    I assume that you are looking for something that will work with any embeded object's not just Word Doc's...right?
    My preference is that A.Doc would be opened by Word (that makes it easier to make changes ... but also makes it possible for another user to make changes). The current need is Word docs, but you are correct assuming that I ultimately seek a method that will work with any embedded object.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  6. #6
    MS Excel MVP VBAX Tutor
    Joined
    Mar 2005
    Posts
    246
    Location
    Try this:

    Sub GetEmbeddedWordObject()
        Dim lReply As Long
        Dim objOLE As OLEObject
        On Error Resume Next
        Set objOLE = ThisWorkbook.Worksheets("Sheet1").OLEObjects(1)
        If Err.Number <> 0 Then
            ' problem with OLE Object
            Exit Sub
        End If
        lReply = MsgBox("Do you want to Open in Word (Yes), or Edit in Place (No)?", vbQuestion + vbYesNoCancel)
        Select Case lReply 
            Case vbYes
                ' To open in a Word instance
                ' like Right Click > Document Object > Open
                objOLE.Verb xlVerbOpen
            Case vbNo
                ' To activate in Excel as Word object
                ' like Right Click > Document Object > Edit
                objOLE.Verb xlVerbPrimary
        End Select
    End Sub
    - Jon
    -------
    Jon Peltier, Microsoft Excel MVP
    Peltier Technical Services
    Tutorials and Custom Solutions
    http://PeltierTech.com
    _______

  7. #7
    VBAX Expert
    Joined
    Feb 2005
    Posts
    924
    Location
    Quote Originally Posted by JonPeltier
    Try this:

    Sub GetEmbeddedWordObject()
        Dim lReply As Long
        Dim objOLE As OLEObject
        On Error Resume Next
        Set objOLE = ThisWorkbook.Worksheets("Sheet1").OLEObjects(1)
        If Err.Number <> 0 Then
            ' problem with OLE Object
            Exit Sub
        End If
        lReply = MsgBox("Do you want to Open in Word (Yes), or Edit in Place (No)?", vbQuestion + vbYesNoCancel)
        Select Case lReply 
            Case vbYes
                ' To open in a Word instance
                ' like Right Click > Document Object > Open
                objOLE.Verb xlVerbOpen
            Case vbNo
                ' To activate in Excel as Word object
                ' like Right Click > Document Object > Edit
                objOLE.Verb xlVerbPrimary
        End Select
    End Sub
    thanks. I will play with this and reply back with comments.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  8. #8
    VBAX Expert
    Joined
    Feb 2005
    Posts
    924
    Location
    Jon: your procedure was very helpful. It gave me the clues and hints to build a very useful general procedure to display embedded objects via VBA.

    Thanks

    MWE
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •