Create Anchor Tag in Word Document

  • Below mentioned code enables the user to provide the anchor tag in word document
  • Sub CreateAnchorTag()

    Dim WApp As Word.Application
    Set WApp = New Word.Application

    FilePath = "C:\Users\PavanKumar\Desktop\Data.docx"

    Dim WDoc As Word.Document
    Set WDoc = WApp.Documents.Open(FilePath)
    WApp.Visible = True
    WDoc.Hyperlinks.Add anchor:=WDoc.Range(11, 25), Address:="https:\\tricks12345.com"
    WDoc.Save
    WDoc.Close

    End Sub

    Download The Workbook