我正在尝试读取SharePoint网站上某个文件夹中文件的标记属性。我有针对本地目录使用它的代码。但是,一旦我将这些路径更改为SharePoint目录,该代码将无法正常工作,因为突然之间,其行为就好像这些文件没有标签一样。有人能向我解释一下吗?我的代码如下:
Dim path As String
Dim FSO As New FileSystemObject
Dim obj_folder As Object
Dim obj_subfolder As Object
Dim subfolders As Object
Dim oDetails As Object
Dim file As Object
Dim lrow As Long
Dim i As Long
Dim x As Long
Dim y As Long
Dim z As Long
path = "\\sharepointpath.com\somefolder\blah folder\"
Set FSO = CreateObject("Scripting.filesystemobject")
Set obj_folder = FSO.GetFolder(path)
Set subfolders = obj_folder.subfolders
lrow = ThisWorkbook.Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row
i = 1
y = 0
z = 0
For x = 1 to 1000000
For Each obj_subfolder In obj_folder.subfolders
For Each file In obj_subfolder.FILES
Set oDetails = GetDetails(file.Path)
Debug.Print oDetails("Tags")
If Instr(1, oDetails("Tags"), "EDGE") > 0 Then
z = z + 1
End If
Next file
Next obj_subfolder
Next x
End Sub
------------------------------------------------------------------------
Public Function GetDetails(sPath as String)
Dim sFolderName As Variant
Dim sFileName As Variant
Dim oShell As Object
Dim oFolder As Object
Dim oFile As Object
Dim oDetails As Object
Dim i As Long
Dim sName As Variant
Dim sValue As Variant
Call SplitFullPath(sPath, sFolderName, sFileName)
Set oShell = CreateObject("Shell.Application")
Set oFolder = oShell.Namespace(sFolderName)
Set oFile = oFolder.ParseName(sFileName)
Set oDetails = CreateObject("Scripting.Dictionary")
For i = 0 To 511
sName = oFolder.GetDetailsOf(oFolder.Items, i)
sValue = oFolder.GetDetailsOf(oFile, i)
If sName <> "" And sValue <> "" Then
oDetails(sName) = sValue
End If
Next
Set GetDetails = oDetails
---------------------------------------------------------------------------
Public Sub SplitFullPath(sPath As String, sFolderName As Variant, sFileName As Variant)
With CreateObject("Scripting.FileSystemObject")
If Not .FileExists(sPath) Then
Exit Sub
End If
sFolderName = .GetParentFolderName(sPath)
sFileName = .GetFileName(sPath)
End With
End Sub
因此,当我使用本地路径运行此代码时,调试会按预期显示每个文件的标记。但是,当我使用SharePoint路径运行此代码时,调试显示的是空白行而不是文件的标记(我在两个位置都使用相同的文件,因此应该相同)。谁能帮忙吗?谢谢!