Add hyperlinks to features using ArcObjects

Last Published: April 25, 2020


This article pertains to ArcGIS versions 8.x. Later versions of ArcGIS may contain different functionality, as well as different names and locations for menus, commands and geoprocessing tools.

This article provides an example of programmatically creating hyperlinks for selected features using ArcObjects.

Support for Visual Basic for Applications (VBA) for ArcMap and ArcCatalog ended with the ArcGIS 10.2.2 release, and Esri has not included VBA compatibility setups since version 10.5. See: ArcGIS Desktop and VBA Moving Forward


  1. Start ArcMap.
  2. Create a new UIButtonControl: How To: Create a new UIButtonControl
For more information on creating a UIControl, see the ArcGIS Desktop Help topic: 'Creating custom commands with VBA and UI Controls'
  1. Right-click the UIButtonControl and select View Source.
  2. Copy this code into the UIButtonControl's click event.
Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pLayer As IFeatureLayer
Dim pHyperlink As IHyperlink
Dim pHyperlinkContainer As IHyperlinkContainer
Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap

'Get the selected features from the layer
Set pLayer = pMxDoc.SelectedLayer
If pLayer Is Nothing Then
  MsgBox "Please select a layer"
  Exit Sub
End If
Dim pFSel As IFeatureSelection
Set pFSel = pLayer
Dim pSelSet As ISelectionSet
Set pSelSet = pFSel.SelectionSet

'Make sure features are selected
If pSelSet.Count < 1 Then
  MsgBox "Please select some features"
  Exit Sub
End If
'Get the hyperlink from the user
Dim strLink As String
strLink = InputBox("Enter the Hyperlink", "Get Hyperlink")

'Loop through the selected features and add the hyperlink
Dim pFeature As IFeature
Dim pCur As IFeatureCursor
pSelSet.Search Nothing, False, pCur
Set pFeature = pCur.NextFeature

'The layer to add hyperlinks
Set pHyperlinkContainer = pLayer
Do Until pFeature Is Nothing
  Set pHyperlink = New Hyperlink
  pHyperlink.LinkType = esriHyperlinkTypeURL
  pHyperlink.Link = strLink
  pHyperlink.FeatureId = pFeature.OID
  pHyperlinkContainer.AddHyperlink pHyperlink
Set pFeature = pCur.NextFeature
  1. Select a layer in the Table of Contents.
  2. Select the features to hyperlink and press the newly created button.
  3. Enter the hyperlink when prompted.

Article ID:000005171

  • ArcMap 8 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options