State about HYPERLINKS Property?

     

     

  • Though this property we can provide links to object
  • It always returns an object
  •  

    Syntax Explanation:

     

  • anchor:It is Mandatory : It is a range or shape
  •  

  • Address:It is Mandatory: It denotes about Address of the shape
  •  

  • Sub Address: It is Optional: Sub address of the shape
  •  

  • Screen tip:It is optional: When cursor put on link., "Screen tip" message will display
  •  

  • Text to display: Text to dispaly to the hyperlink
  •  

    Assigning HYPERLINK to a OBJECT:

     

     

    As per our requirement we can assign hyperlink to either OBJECT (or) TEXT

     

    1)Assigning HYPERLINKS to an OBJECT:

     

    Copy the Code:

     

    Sub Add_Hperlinks_to_Object()
    ActiveSheet.Hyperlinks.Add _
    Anchor:=Sheets("Sheet2").Shapes("click"), _
    Address:="http://www.sriguranjani.com/VBA_Hyperlinks_

    Property.html", _
    SubAddress:="", _
    ScreenTip:="View on Website"
    End Sub

     

     

    2)Assigning HYPERLINKS to TEXT:

     

  • Hyperlink assinged to text which is mentioned in range G13
  • Copy the Code:
  •  

    Sub Add_Hperlinks_to_Object()
    ActiveSheet.Hyperlinks.Add _
    Anchor:=Sheets("Sheet2").Range("G13"), _
    Address:="http://www.sriguranjani.com/VBA_Hyperlinks_
    Property.html", _
    SubAddress:="", _
    ScreenTip:="View on Website"
    End Sub

     

     

     

    3)Collection of sheet names in a WORKBOOK and provide HYPERLINKs:

     

     

    Private Sub CommandButton1_Click()
    Dim i As Integer
    For i = 1 To Sheets.Count
    Cells(i, 1).Value = Sheets(i).Name
    ActiveCell.Hyperlinks.Add _
    anchor:=Cells(i, 1), _
    Address:="", _
    SubAddress:=Sheets(i).Name & "!A1", _
    ScreenTip:="Hi click here to view the sheet"
    Next
    End Sub