Vba 打印自定义文档属性

Vba 打印自定义文档属性,vba,word-2010,custom-properties,Vba,Word 2010,Custom Properties,这是我目前的代码 Sub PrintMasterTime() Dim PropVal As Integer PropVal = ActiveDocument.CustomDocumentProperties(MasterTime).Value Print PropVal End Sub 编译错误:方法没有合适的对象无效 不知道为什么不打印“MasterTime”是我的自定义文档属性的名称。您需要使用字符串调用CustomDocumentProperties。你忘了引用 Pr

这是我目前的代码

Sub PrintMasterTime()

Dim PropVal As Integer
    PropVal = ActiveDocument.CustomDocumentProperties(MasterTime).Value
    Print PropVal

End Sub
编译错误:
方法没有合适的对象无效


不知道为什么不打印<代码>“MasterTime”是我的自定义文档属性的名称。

您需要使用字符串调用
CustomDocumentProperties
。你忘了引用

PropVal = ActiveDocument.CustomDocumentProperties("MasterTime").Value

和。我认为不能从集合属性调用
.Value
。可以从常规文档属性调用.Value并将其存储为变量吗?那对我来说就足够了。