Properties 属性

       

返回一个 CustomProperties 对象,该对象代表智能标记的属性。

expression.Properties

expression   必需。该表达式返回一个 SmartTag 对象。

说明

虽然使用 Add 方法可在 Microsoft Word Visual Basic for Applications 工程中添加自定义属性,但是自定义属性通常是由智能标记标识符和操作文件指定的。

示例

本示例循环遍历当前文档中的所有智能标记,然后创建一篇新文档并列出具有自定义属性的所有智能标记的自定义属性的名称和值。

Sub SmartTagProps()
    Dim docNew As Document
    Dim stgTag As SmartTag
    Dim stgProp As CustomProperty
    Dim intTag As Integer
    Dim intProp As Integer

    'Create new document and add heading content
    Set docNew = Documents.Add

    With docNew.Content
        .InsertAfter "Name" & vbTab & "Value"
        .InsertParagraphAfter
    End With

    'Loop through smart tags in current document
    For intTag = 1 To ThisDocument.SmartTags.Count

        With ThisDocument.SmartTags(intTag)

            'Verify that a smart tag has properties
            If .Properties.Count > 0 Then

                'Enter the name and value of properties into new document
                For intProp = 1 To .Properties.Count
                    docNew.Content.InsertAfter .Properties(intProp) _
                        .Name & vbTab & .Properties(intProp).Value
                    docNew.Content.InsertParagraphAfter
                Next
            Else

                'Display message if no properties for smart tag
                MsgBox "There are no custom properties for this smart tag."
            End If
        End With
    Next

    'Convert the tabbed list in the new document to a table
    docNew.Content.Select
    Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=2

End Sub