我对此进行了大量研究并找到了许多帮助站点,但仍然无法理解为什么有时这不起作用。
我正在尝试访问一个共享点站点(对我没有限制)并提取该站点内文件夹中的所有文件。
有时我的路径有效并且它可以做到,有时它不会。我有一种感觉,如果我之前在浏览器上进入过 sharepoint 站点但无法确认(因为我现在又试了一次,但它不起作用 ARGGH)。但是下面的相同代码在过去也有效。
它在下面的文件系统对象功能上失败
Public Function GetFullFileName(strfilepath As String, _
strFileNamePartial As String) As String
Dim objFS As Variant
Dim objFolder As Variant
Dim objFile As Variant
Dim intLengthOfPartialName As Integer
Dim strfilenamefull As String
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strfilepath)
'work out how long the partial file name is
intLengthOfPartialName = Len(strFileNamePartial)
For Each objFile In objFolder.Files
'Test to see if the file matches the partial file name
If Left(LCase(Replace(objFile.Name, " ", "")), intLengthOfPartialName) = LCase(strFileNamePartial) Then
'get the full file name
strfilenamefull = objFile.Name
Exit For
Else
End If
Next objFile
'Return the full file name as the function's value
GetFullFileName = strfilenamefull
End Function
当它到达 GetFolder(strfilepath) 代码时,我得到一个“运行时错误'76':找不到路径”
strfilepath 只是一个常规的共享点站点名称(例如,\teams.uk\gm\FX\SharedDocuments\London\11) November 2013\20 November\Reports)
如前所述,我尝试了文件路径的不同变体,包括 DavWWW,但似乎没有任何效果,我不知道还能尝试什么。
请问有什么建议吗?
谢谢
赖扬