答案 0 :(得分:1)
您可以尝试以下代码:
Dim fileProperty As Variant
For Each fileProperty In ActiveWorkbook.BuiltinDocumentProperties
Debug.Print fileProperty.Name
Next fileProperty
我知道这不是完整的代码,但您也可以使用.BuiltinDocumentProperties("Content Status")
如果有效,请告诉我。
答案 1 :(得分:1)
Florent B发布的代码工作正常。但是,我没有在提到的索引上得到所需的属性,即127.相反,我在计算机上得到129。我不确定它的原因。
我的建议如下。创建自定义函数。
重要提示:按指示设置参考,否则无效。我尝试过后期绑定,但代码失败,所以这个设置很关键。
Public Function GetExtendedProperty(strFolder As String, _
strFile As String, _
strProperty As String) As String
'\\ Set Reference to "Microsoft Shell Controls and Automation" Library (shell32.dll) in VBE
Dim wShell As Shell
Dim fld As folder
Dim itm As FolderItem
Dim i As Long
Set wShell = CreateObject("Shell.Application")
Set fld = wShell.Namespace(strFolder)
Set itm = fld.ParseName(strFile)
For i = 0 To 255
If CStr(fld.GetDetailsOf(fld.Items, i)) = strProperty Then
GetExtendedProperty = fld.GetDetailsOf(itm, i)
End If
Next i
Set itm = Nothing
Set fld = Nothing
Set wShell = Nothing
End Function
然后可以在实际代码中使用如下所示。
Sub Test()
Dim strComplStatus As String
strComplStatus = GetExtendedProperty("C:\Temp", "Book1.xlsx", "Content status")
MsgBox strComplStatus
End Sub