Project.CustomDocumentProperties 屬性(專案)Project.CustomDocumentProperties property (Project)

會取得 DocumentProperties 集合,代表文件的自訂屬性。Gets a DocumentProperties collection representing the custom properties of the document. 唯讀的 ObjectRead-only Object.


expressionexpression. CustomDocumentProperties

_運算式_代表**Project** 物件的變數。expression A variable that represents a Project object.


如需詳細資訊,請參閱《 Microsoft Office Visual Basic 參考資料》中的_DocumentProperties 集合物件_。For more information, see DocumentProperties Collection Object in the Microsoft Office Visual Basic Reference.

若要使用此屬性,您必須使用 [ 工具 ] 功能表上的 [ 參考 命令包含 Microsoft Office 14.0 物件程式庫參考。To use this property, you must include a reference to the Microsoft Office 14.0 Object Library by using the References command on the Tools menu. 物件程式庫包含的 Visual Basic 物件、 屬性、 方法及常數用來操作文件屬性的定義。The Object Library contains definitions for the Visual Basic objects, properties, methods, and constants used to manipulate document properties.

可以使用 BuiltinDocumentProperties 屬性傳回內建文件內容的集合。Use the BuiltinDocumentProperties property to return the collection of built-in document properties.


在下列範例中, 完成日期自訂屬性值就是 Nothing如果屬性新增至專案,但未完成的專案。In the following example, the Date completed custom property value would be Nothing if the property is added to the project, but the project is not completed. 在執行 TestDocProps範例之前,新增至作用中的某些工作 project 並且指派給資源。Before you run the TestDocProps example, add some tasks to the active project and assign them to a resource.

Sub TestDocProps()
    Dim docProps As Office.DocumentProperties
    Dim docProp As Office.DocumentProperty
    Dim numProps As Integer
    Set docProps = ActiveProject.CustomDocumentProperties
    numProps = docProps.Count
    Debug.Print "Number of custom document properties: " & numProps
    For Each docProp In docProps
        If (docProp.Name = "Date completed") Then
            Debug.Print "Date completed: (none) "
            Debug.Print docProp.Name & vbTab & ": " & docProp.Value
        End If
    Next docProp
End Sub

下面是 TestDocProps巨集,並沒有新增的 完成日期屬性的專案的結果:Following are the results of the TestDocProps macro, for a project that does not have the Date completed property added:

Number of custom document properties: 7
% Complete  : 0%
Cost    : $0.00
Duration    : 5 days?
Finish  : Thu 5/7/09
Start   : Fri 5/1/09
Work    : 40h
% Work Complete : 0%

支援和意見反應Support and feedback

有關於 Office VBA 或這份文件的問題或意見反應嗎?Have questions or feedback about Office VBA or this documentation? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.