【问题标题】:What is the syntax for VBA ContentTypeProperties for parent 'Document Set'-name?父“文档集”名称的 VBA ContentTypeProperties 的语法是什么?
【发布时间】:2021-06-01 17:40:05
【问题描述】:

我正在尝试从 Excel 文件所在的父“文档集”获取 VBA 中的 ContentTypeProperties(以在 Excel 的单元格中填充元数据值)。有人知道我需要哪个值吗?

我已经可以获取添加到文档集中的自定义添加元数据列,但找不到该文档集的标准“标题”或“名称”属性?

Function GetDocProp(DocProp As String) As String
GetDocProp = ActiveWorkbook.ContentTypeProperties(DocProp)
End Function

【问题讨论】:

    标签: excel vba sharepoint


    【解决方案1】:

    ContentTypeProperties 属性根据文档返回一个 MetaProperties 集合。

    返回描述存储的元数据的 MetaProperties 集合 在工作簿中。只读。

    查看它的属性和方法,有一个函数GetItemByInternalName(),它返回一个MetaProperty对象。

    所以,应该是这样的(没测试过)。

    Dim props as MetaProperties 
    Set props = ActiveWorkbook.ContentTypeProperties
    
    Dim prop As MetaProperty
    Set prop = props.GetItemByInternalName(DocProp)
    
    Dim value As Variant
    value = prop.Value
    

    在一行中,应该是:

    GetDocProp = ActiveWorkbook.ContentTypeProperties.GetItemByInternalName(DocProp).Value
    

    【讨论】:

    • 我尝试如下: Function GetDocProp(DocProp As String) As String GetDocProp = ActiveWorkbook.ContentTypeProperties.GetItemByInternalName(DocProp).Value End Function 然后在 Excel 中我尝试了 =getdocprop("Title")但只给我“#VALUE!”。有什么建议吗?谢谢!
    • 尝试在即时窗口中运行它以查看它返回的内容:?ActiveWorkbook.ContentTypeProperties.GetItemByInternalName("Title").Value
    • 我得到一个“编译错误无效使用属性”,我尝试使用“名称”而不是“标题”,结果相同。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-15
    • 1970-01-01
    • 1970-01-01
    • 2021-02-14
    相关资源
    最近更新 更多