返回 ListFields 集合,该集合代表当前列表中的所有域。ListFields 集合包含与列表成员文档的列属性相对应的 ListField 对象。
expression.Fields
expression 必选。返回“应用于”列表中的对象之一的表达式。
下列示例显示 Lists 集合第一个列表中的所有域名。
Sub DisplayFields()
'Returns the fields collection
Dim objApp As FrontPage.Application
Dim lstWebList As List
Dim lstFields As ListFields
Dim lstField As ListField
Dim StrName As String
Set objApp = FrontPage.Application
Set lstWebList = objApp.ActiveWeb.Lists.Item(0)
Set lstFields = lstWebList.Fields
If Not ActiveWeb.Lists Is Nothing Then
For Each lstField In lstFields
'add URLs to string
If StrName = "" Then
'If empty string
StrName = lstField.Name & vbCr
Else
'add names to string
StrName = StrName & lstField.Name & vbCr
End If
Next
'Display formatted string
MsgBox "The list " & lstWebList.Name & _
"contains the following fields" & vbCr & vbCr & _
StrName
Else
'Otherwise display message to user
MsgBox "The current web contains no lists."
End If
End Sub