发布服务器) (Fields 对象

字段 集合 代表文字范围中的所有域的对象。

备注

出版物中此集合的 Count 属性返回指定形状或选定内容中的项数。

使用 TextRange.Fields 属性可返回 Fields 集合。 使用 Fields (索引) (其中 index 是索引号)返回单个 Field 对象。 索引号代表选定内容、 范围或出版物中字段的位置。

示例

下面的示例在当前出版物中每个文本框中显示域代码和结果的第一个字段。

Sub ShowFieldCodes() 
 Dim pagPage As Page 
 Dim shpShape As Shape 
 
 For Each pagPage In ActiveDocument.Pages 
 For Each shpShape In pagPage.Shapes 
 If shpShape.Type = pbTextFrame Then 
 With shpShape.TextFrame.TextRange 
 If .Fields.Count > 0 Then 
 MsgBox "Code = " & .Fields(1).Code & vbLf _ 
 & "Result = " & .Fields(1).Result & vbLf 
 End If 
 End With 
 End If 
 Next 
 Next 
End Sub

方法

属性

另请参阅

支持和反馈

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