|Hotlink a Feature Layer to a Web Site
The sample demonstrates one way to hotlink a feature layer to web pages.
Hotlinks use a field in the database to store the hyperlink address for
a web page, document, or macro. When a hotlink is created for a feature
layer, every feature in the layer is linked to the item listed in its
hotlink field. If hotlink field is empty for a feature, that feature
is simply not linked to anything.
Hyperlinks differ from hotlinks in that they are set up for an
individual feature rather than an entire feature layer. In addition,
hyperlinks do not use a field in the database to store the path to
the link. See the Hyperlink Sample for an example of this.
Hyperlinks and hotlinks support three link types: documents, urls,
How to use:
- Paste the code into VBA.
- Modify the code to reflect the correct hot link field. This sample
is hard-coded to use a field called WebLink.
- Select a feature layer in the table of contents.
- Make sure at least one feature from this layer has a
web address in its hot link field.
- Run the AddHotlink Macro.
- Select the Hyperlink tool.
- All the features in this layer with a valid hot link field value
should be outlined in blue.
- Using the Hyperlink tool, click on one of the features to launch
that features linked in web site.
Public Sub AddHotlink()
Set pMxDoc = Application.Document
Set pContentsView = pMxDoc.CurrentContentsView
If TypeOf pContentsView.SelectedItem
Set pHotlinkContainer = pContentsView.SelectedItem
pHotlinkContainer.HotlinkField = "WebLink"
pHotlinkContainer.HotlinkType = esriHyperlinkTypeURL