+ Reply to Thread
Results 1 to 10 of 10

Create hyperlinks with Shapes

  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Create hyperlinks with Shapes

    This code finds and matches the Text value of a Shape to the value of a cell on seperate worksheets within the same workbook.
    Please Login or Register  to view this content.
    Questions:
    How can I write code to create a hyper link from the Shape to the cell? If the user clicks on the shape it links to a cell and vise~versa.
    My attempt above fails, it seems to go thru the first found shape but generates an error after the second found shape.
    No hyperlinks are created.

    Run-time error '5':
    Invalid procedure call or argument
    Last edited by Rick_Stanich; 02-09-2010 at 02:12 PM. Reason: Better title
    Regards

    Rick
    Win10, Office 365

  2. #2
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: Create hyperlinks with Shapes

    Looks like a cell selection problem in the loop. The add hyperlink statement is inside of the ShtCell loop. The first time a hyperlink is added to link to the first ShtCell value. The second time, a hyperlink with SubAddress for the previous ShpCell already exists for ShpTemp, so the add fails.
    Bob
    Click my star if my answer helped you. Mark the thread as [SOLVED] if it has been.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Create hyperlinks with Shapes

    Here's a simplified example, Rick:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Create hyperlinks with Shapes

    blane245
    I understand, will look into that.
    Two Q's for shg.
    1. This generates and error
    Please Login or Register  to view this content.
    Run-time error '91':
    Object variable or with block variable not set
    2. How does your example utilize sheet 1 column D for the comparison of "shp.TextFrame.Characters.Text"?

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Create hyperlinks with Shapes

    1. I'd need to see your workbook to see whay it's generating an error

    2. It doesn't; I created a simple stand-alone example that matches shape text to column A.

  6. #6
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Create hyperlinks with Shapes

    No images have been harmed in making this excel workbook.

    None of the images on sheet "Op60" are locked down.

    See attached file.
    Attached Files Attached Files

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Create hyperlinks with Shapes

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Create hyperlinks with Shapes

    And I was almost there! I created hyperlinks but they exist on the same sheet (sheet Op60).
    Setting shtCell to a variable removed the initial error.
    Please Login or Register  to view this content.
    It kills me how you (and others here) can simplify what appears to be complicated instructions (macros).
    Your example works as written.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Create hyperlinks with Shapes

    This line,
    Please Login or Register  to view this content.

    ... should be cleaned up to add all the other arguments (MatchCase, LookAt, ...) that default to the prior state.

  10. #10
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Create hyperlinks with Shapes

    Got it, thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.6.0 RC 1