Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internal hyperlinks in VBA (Office 2003)

    I'm trying to add some internal hyperlinks to a worksheet in VBA, and struggling. What I want to do is add a hyperlink to the same cell in a different worksheet. The code I'm using is <span style="background-color: #FFFF00; color: #000000; font-weight: bold">R.Hyperlinks.Add R, "Sheet2", R.AddressLocal</span hi> where R is a Range (set to a single cell) but that fails. What's the correct syntax?

    <img src=/S/whisper.gif border=0 alt=whisper width=29 height=17>And why does the Microsoft help on hyperlinks only refer to external hyperlinks?
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Internal hyperlinks in VBA (Office 2003)

    Try

    R.Hyperlinks.Add R, "", "Sheet2!" & R.Address

  3. #3
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    Perfect, thanks Hans.
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Thanks

    For others reading this:

    The syntax to create a hyperlink in Excel VBA is

    object.Hyperlinks.Add Anchor, Address, SubAddress, ScreenTip, TextToDisplay

    object can be a sheet or a range.
    Anchor is the range or shape the hyperlink is attached to.
    Address specifies the "document" the hyperlink points to: a web address or the path and name of a file. If this is the active workbook itself, you must specify an empty string "" as Address.
    SubAddress specifies the location within the "document" the hyperlink points to: a bookmark in a Word document, a cell range in an Excel workbook etc.
    ScreenTip specifies the text to be displayed when the user hovers the mouse over the Anchor
    TextToDisplay is the text displayed in the Anchor.

    Anchor and Address are required, the other arguments are optional.

Posting Permissions

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