全部显示

Hyperlink 属性

       

使用 Hyperlink 属性可以返回对 Hyperlink 对象的引用。Hyperlink 属性可用来访问与命令按钮图像标签控件关联的 Hyperlink 对象的属性和方法。只读。

expression.Hyperlink

expression  必需。返回“Applies To”列表中的一个对象的表达式。

说明

Hyperlink 属性仅在使用 Visual Basic 时才可用。

示例

在下面的示例中,CreateHyperlink 过程将命令按钮、标签或图像控件的超链接属性设置为传递到过程的地址和子地址值。地址设置是可选参数,因为链接到当前数据库中对象的超链接只使用子地址设置。若要测试此示例,请创建一个含有两个文本框控件(txtAddresstxtSubAddress)和一个命令按钮 (cmdFollowLink) 的窗体,并将下列代码粘贴到窗体模块的“声明”节。

Private Sub cmdFollowLink_Click()
    CreateHyperlink Me!cmdFollowLink, Me!txtSubAddress, _
         Me!txtAddress
End Sub

Sub CreateHyperlink(ctlSelected As Control, _
     strSubAddress As String, Optional strAddress As String)
    Dim hlk As Hyperlink
    Select Case ctlSelected.ControlType
        Case acLabel, acImage, acCommandButton
            Set hlk = ctlSelected.Hyperlink
            With hlk
                If Not IsMissing(strAddress) Then
                    .Address = strAddress
                Else
                    .Address = ""
                End If
                .SubAddress = strSubAddress
                .Follow
                .Address = ""
                .SubAddress = ""
            End With
        Case Else
            MsgBox "The control '" & ctlSelected.Name _
                 & "' does not support hyperlinks."
    End Select
End Sub