+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    10-22-2008
    Location
    Australia
    Posts
    1

    Link to Embedded Object (OLE)

    Hi,
    This question has been raised numerous times on different forums but has not been given an adequate answer.

    I have embedded objects - a number of pdf files - on an empty worksheet in excel. I would like to create a number of hyperlinks (or similar) on a seperate worksheet within the same file that open each individual file.
    i.e.:
    link 1 - opens pdf1
    link 2 - opens pdf2
    etc.

    A normal hyperlink simply links to a designated cell - however the embedded objects are an icon that floats above the cell so excel doesnt recognise the object.

    is it possible to be able to click on the link which will directly open up the document, but not divert you to the seperate worksheet where the .pdfs are embedded?

    im thinking i could create a macros/VBA button to do it? this i dont know how to do so would appreciate some help - otherwise if theres any other solutions please try to help - im desperate!

  2. #2
    Registered User
    Join Date
    04-27-2011
    Location
    Lima, Peru
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Link to Embedded Object (OLE)

    I could definitely see the value of this question. You are trying to containerize all your pdf's inside a workbook, so that the user doesn't have a million files to look at.

    I was wondering if this question had been answered. But maybe there is another way to ask the question. Is there a way for excel to recognize an embedded object so that a hyperlink could point to it? Could the embedded object be assigned a name so that it appears as an object when you try to create a hyperlink in the same document?

    Does anyone have the answer to these questions?

  3. #3
    Registered User
    Join Date
    09-28-2011
    Location
    NJ
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Link to Embedded Object (OLE)

    Here's an OK, not great, way to do this. The user clicks the cell referring to the file, then clicks a "View File" button. If you make changes to the list of files (other than adding to the end), it starts to fall apart.

    1. Create a list of the file names in column A on Sheet 1.
    2. Create this VBA macro:
    Code:
    Sub ActivateObj()
    
    Dim myCell As Range
    Dim mySheet As Object
    Dim myFile As Object
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    
    Set myCell = ActiveCell
    Set mySheet = ActiveSheet
    If mySheet.Name <> "Sheet1" Or myCell.Column <> 1 Or myCell.Value = "" Then
        MsgBox ("Please select a file in column A on Sheet 1")
        Exit Sub
    End If
    On Error GoTo noObject
    Set myFile = ThisWorkbook.Sheets(2).OLEObjects(Evaluate("R_" & myCell.Row))
    On Error Resume Next
    myFile.Verb Verb:=xlVerbOpen
    Set myFile = Nothing
    mySheet.Select
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    Exit Sub
    
    noObject:
    MsgBox ("No file embedded for " & ActiveCell.Value)
    
    End Sub
    3. Place a button on Sheet 1 labeled "View File", and associate it with the macro.
    4. For each file name,
    a. Note the row number that the file is on
    b. Embed the file on Sheet 2
    c. Single click the embedded file icon
    d. Define a name in the form "R_n", where n is the row number from 4.a.
    Another way to do this that doesn't break if you change the list is to use the name of the file as the defined name of the embedded object in step 4d. In that case, you'd replace this line:
    Code:
    Set myFile = ThisWorkbook.Sheets(2).OLEObjects(Evaluate("R_" & myCell.Row))
    with this:
    Code:
    Set myFile = ThisWorkbook.Sheets(2).OLEObjects(Evaluate(myCell.Value))
    The problem with this approach is that defined names can only contain letters, underscores (_), and numbers; file names can have many other characters in them.

  4. #4
    Non English Excel Moderator arthurbr's Avatar
    Join Date
    12-23-2006
    Location
    Belgium
    MS-Off Ver
    XL2003
    Posts
    6,055

    Re: Link to Embedded Object (OLE)

    This is a 3 year old thread. Don't expect much response from OP
    Quoting entire posts clutters the forum and makes threads hard to read !

    If you are pleased with a member's answer then use the Star icon to rate it

    Click here to see forum rules

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0