【问题标题】:VBA: How to Read SharePoint Properties (DocumentTypeProperties) for Visio Files?VBA:如何读取 Visio 文件的 SharePoint 属性 (DocumentTypeProperties)?
【发布时间】:2019-06-25 13:10:47
【问题描述】:

我正在尝试读取 SharePoint 文档库中 Visio 文件的 SharePoint 属性(如版本)。

在 Word、Excel 和 PowerPoint 中,您可以使用 VBA 通过 ActiveDocument (Word)、Workbook (Excel) 或 ActivePresentation (Powerpoint) 的属性“.DocumentTypeProperties”读取 SharePoint 属性。显示具有所有 SharePoint 属性的消息框的 PowerPoint 示例:

Option Explicit

Sub printContentTypeProperties()
    Dim prop As Variant
    Dim propstr$
    propstr$ = ""
    For Each prop In ActivePresentation.ContentTypeProperties
        Select Case VarType(prop.Value)
        Case 8: ' String
            propstr$ = propstr$ & prop.Name & ": " & prop.Value & Chr$(10)
        Case 2 To 6 Or 14 Or 17 Or 20: ' Number (numeric value)
            propstr$ = propstr$ & prop.Name & ": " & Str$(prop.Value) & Chr$(10)
        Case Else:
            propstr$ = propstr$ & prop.Name & ": " & "NO_STRING_OR_NUMBER" & Chr$(10)
        End Select
    Next prop
    MsgBox propstr$
End Sub

我确实在 Google、StackOverflow 上搜索了很长时间,但我找不到如何读取 Visio 文件的 SharePoint 属性。 Visio 的“Document”对象(请参阅https://docs.microsoft.com/de-de/office/vba/api/visio.document)没有属性“DocumentTypeProperties”。

是否可以使用 VBA for Visio 文件读取 SharePoint 属性?需要哪个 Visio 版本(标准版或专业版)?

【问题讨论】:

标签: vba sharepoint properties metadata visio


【解决方案1】:

没有用于从 Visio 文件读取(用户定义的)Visio 文件 SharePoint 属性的 API。

不过,您始终可以自己解析 Visio 文件。如果文件中存在这些属性,您将能够获取它们,因为 Visio 文件现在只是一堆压缩的 xml 文件(假设文件不是旧的二进制格式)

【讨论】:

  • 谢谢 Nikolay,我会尝试自己解析 xml 文件。
【解决方案2】:

AFAIk 没有DocumentTypeProperties,但您可以直接从document 对象访问标准的。 MSDN Discussion

ThisDocument.FullName
ThisDocument.TimeCreated
ThisDocument.Creator

如果您想在 Document 中保存一些信息,可以将它们保存在 Document ThisDocument.DocumentSheet 的 Shapsheet 中,目前我还没有找到更好的选择。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-14
    • 1970-01-01
    • 2021-10-23
    • 2019-12-09
    相关资源
    最近更新 更多