我已经做了大量的研究,并找到了很多帮助网站,但仍不明白为什么有时无法使用。使用VBA从Sharepoint文件夹获取文件名
我试图访问一个SharePoint站点(对我来说没有任何限制),并提取该站点内某个文件夹中的所有文件。
有时我的路径工作,它做到了,其他时间没有。如果我之前进入了浏览器的sharepoint站点,但我无法证实这一点(因为我现在再试一次,并且它不起作用),我感觉它起作用了。但是,以下相同的代码在过去有效。
它的失败上的文件系统对象的功能如下
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
我得到一个“运行时错误‘76’:找不到路径”,当它到达的GetFolder(strfilepath)代码
strfilepath只是一个普通的sharepoint站点名称(比如像\ teams.uk \ gm \ FX \ SharedDocuments \ London \ 11)2013年11月\ 20 November \ Reports)
正如我已经提到过的,包括DavWWW的路径,但似乎没有工作,我不知道什么els e试试。
有什么建议吗?
感谢
Raiyan
可能是因为网络连接? – jacouh
不要这么想 - 我可以直接进入sharepoint站点并访问它? – user2599240
为什么使用FileSystemObject访问SharePoint站点上的文档? SharePoint文档位于由SharePoint创建的虚拟路径中,而FileSystemObject不知道它们的任何内容。您应该使用SharePoint API访问SharePoint站点上的文档。 也许你正在使用某种COM对象? –