VBA:如何读取 Visio 文件的 SharePoint 属性 (DocumentTypeProperties)?
VBA: How to Read SharePoint Properties (DocumentTypeProperties) for Visio Files?
我正在尝试读取 SharePoint 文档库中 Visio 文件的 SharePoint 属性(如版本)。
在 Word、Excel 和 PowerPoint 中,您可以使用 VBA 通过 属性“.DocumentTypeProperties”读取 ActiveDocument (Word)、工作簿 (Excel ) 或 ActivePresentation (Powerpoint)。显示包含所有 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、Whosebug 上搜索了很长时间,但我找不到如何读取 Visio 文件的 SharePoint 属性。 Visio 的“文档”对象(参见 https://docs.microsoft.com/de-de/office/vba/api/visio.document)没有 属性“DocumentTypeProperties”。
是否可以使用 VBA 读取 Visio 文件的 SharePoint 属性?需要哪个 Visio 版本(标准版或专业版)?
AFAIk 没有 DocumentTypeProperties
,但您可以直接从 document
对象访问标准的。 MSDN Discussion
ThisDocument.FullName
ThisDocument.TimeCreated
ThisDocument.Creator
如果您想在文档中保存一些信息,可以将它们保存在文档的 Shapsheet 中ThisDocument.DocumentSheet
,目前我还没有找到更好的选择。
没有 API 可从 Visio 文件读取 (user-defined) Visio 文件 SharePoint 属性。
尽管如此,您始终可以自己解析 Visio 文件。如果文件中存在这些属性,您将能够获取它们,因为 Visio 文件现在只是一堆压缩的 xml 文件(假设文件不是旧的二进制格式)
我正在尝试读取 SharePoint 文档库中 Visio 文件的 SharePoint 属性(如版本)。
在 Word、Excel 和 PowerPoint 中,您可以使用 VBA 通过 属性“.DocumentTypeProperties”读取 ActiveDocument (Word)、工作簿 (Excel ) 或 ActivePresentation (Powerpoint)。显示包含所有 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、Whosebug 上搜索了很长时间,但我找不到如何读取 Visio 文件的 SharePoint 属性。 Visio 的“文档”对象(参见 https://docs.microsoft.com/de-de/office/vba/api/visio.document)没有 属性“DocumentTypeProperties”。
是否可以使用 VBA 读取 Visio 文件的 SharePoint 属性?需要哪个 Visio 版本(标准版或专业版)?
AFAIk 没有 DocumentTypeProperties
,但您可以直接从 document
对象访问标准的。 MSDN Discussion
ThisDocument.FullName
ThisDocument.TimeCreated
ThisDocument.Creator
如果您想在文档中保存一些信息,可以将它们保存在文档的 Shapsheet 中ThisDocument.DocumentSheet
,目前我还没有找到更好的选择。
没有 API 可从 Visio 文件读取 (user-defined) Visio 文件 SharePoint 属性。
尽管如此,您始终可以自己解析 Visio 文件。如果文件中存在这些属性,您将能够获取它们,因为 Visio 文件现在只是一堆压缩的 xml 文件(假设文件不是旧的二进制格式)