Publisher) (Hyperlinks 对象

表示 超链接 的集合 在文字范围中的对象。

备注

使用 TextRange.Hyperlinks 属性可返回 Hyperlinks 集合。

使用 添加 若要创建超链接,并将其添加到 超链接 集合的方法。

使用 Hyperlinks (索引) (其中 index 是索引号)返回出版物、区域或选定内容中的单个 Hyperlink 对象。

该集合的 Count 属性只返回指定形状或选定内容中超链接的数量。

示例

以下示例删除当前出版物中地址中包含 Tailspin 一词的所有文本超链接。

Sub DeleteMSHyperlinks() 
 Dim pgsPage As Page 
 Dim shpShape As Shape 
 Dim hprLink As Hyperlink 
 For Each pgsPage In ActiveDocument.Pages 
 For Each shpShape In pgsPage.Shapes 
 If shpShape.HasTextFrame = msoTrue Then 
 If shpShape.TextFrame.HasText = msoTrue Then 
 For Each hprLink In shpShape.TextFrame.TextRange.Hyperlinks 
 If InStr(hprLink.Address, "tailspin") <> 0 Then 
 hprLink.Delete 
 Exit For 
 End If 
 Next 
 Else 
 shpShape.Hyperlink.Delete 
 End If 
 End If 
 Next 
 Next 
End Sub

以下示例创建指向指定网站的新超链接。

Sub AddHyperlink() 
 Selection.TextRange.Hyperlinks.Add Text:=Selection.TextRange, _ 
 Address:="https://www.tailspintoys.com/" 
End Sub

如果指定的选定内容包含超链接,则本示例显示第一个超链接的地址。

Sub DisplayHyperlinkAddress() 
 With Selection.TextRange.Hyperlinks 
 If .Count > 0 Then _ 
 MsgBox .Item(1).Address 
 End With 
End Sub

方法

属性

另请参阅

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。