FollowHyperlink 方法

此頁沒有內(nèi)容條目
內(nèi)容

expandtri全部顯示

FollowHyperlink 方法可打開由超鏈接地址指定的文檔或網(wǎng)頁。

expression.FollowHyperlink(Address, SubAddress, NewWindow, AddHistory, ExtraInfo, Method, HeaderInfo)

expression    必需。返回“應(yīng)用于”列表中的一個對象的表達式。

Address     必需,String 型。確定有效超鏈接地址的字符串表達式。

SubAddress     可選,String 型。字符串表達式,用于確定由 address   參數(shù)指定的文檔中的命名位置。默認(rèn)值為空字符串 (" ")。

NewWindow     可選,Boolean 型。Boolean 值,該值為 True (–1) 時,將在新窗口中打開文檔;該值為 False (0) 時,則在當(dāng)前窗口中打開文檔。默認(rèn)值為 False。

AddHistory     可選,Boolean 型。Boolean 值,該值為 True 時,將添加指向“歷史記錄”文件夾的超鏈接,該值為 False 時,則不添加指向“歷史記錄”文件夾的超鏈接。默認(rèn)值為 True。

ExtraInfo     可選,Variant 型。字符串Byte 數(shù)據(jù)數(shù)組,用于指定定位到超鏈接的其他信息。例如,該參數(shù)可以用來為 .ASP 或 .IDC 文件指定搜索參數(shù)。在 Web 瀏覽器中,extrainfo   參數(shù)可能出現(xiàn)在超鏈接地址后,并用問號 (?) 與地址分開。指定 extrainfo 參數(shù)時,不包括問號。

Method   可選 MsoExtraInfoMethod。Integer 值,用于指定 extrainfo   參數(shù)的附加方式。method 參數(shù)可以是下列固有常量之一。

MsoExtraInfoMethod 可以是這些 MsoExtraInfoMethod 常量之一。

msoMethodGet default。extrainfo 參數(shù)將附加到超鏈接地址且只能是字符串。在默認(rèn)情況下將傳遞該值。

msoMethodPost。extrainfo 參數(shù)作為字符串或 Byte 數(shù)據(jù)類型的數(shù)組傳遞。

HeaderInfo     可選 String 型。 用于指定頁眉信息的字符串。默認(rèn)情況下,headerinfo   參數(shù)是空字符串。

說明

通過使用 FollowHyperlink 方法,可以跟隨一個不存在于控件中的超鏈接。該超鏈接可以由您或其他用戶提供。例如,可以提示用戶在對話框中輸入超鏈接地址,然后使用 FollowHyperlink 方法來跟隨該超鏈接。

瀏覽到某個超鏈接時,可以使用 extrainfo 和 method 參數(shù)來提供其他信息。例如,可以為搜索引擎提供參數(shù)。

可以使用 Follow 方法來跟隨與控件相關(guān)聯(lián)的超鏈接。

示例

下列函數(shù)提示用戶輸入一個超鏈接地址,然后跟隨該超鏈接:

Function GetUserAddress() As Boolean

    Dim strInput As String

    On Error GoTo Error_GetUserAddress

    strInput = InputBox("Enter a valid address")

    Application.FollowHyperlink strInput, , True

    GetUserAddress = True

Exit_GetUserAddress:

    Exit Function

Error_GetUserAddress:

    MsgBox Err & ": " & Err.Description

    GetUserAddress = False

    Resume Exit_GetUserAddress

End Function

可以用以下的過程來調(diào)用該函數(shù):

Sub CallGetUserAddress()

    If GetUserAddress = True Then

        MsgBox "Successfully followed hyperlink."

    Else

        MsgBox "Could not follow hyperlink."

    End If

End Sub