是否有一种防弹方式来确定当前是否可以访问SharePoint文件夹?我正在使用UNC路径,即“\\ mycompany \ mySharePoint \ mySite \ myFolder”
我正在使用FileSystemObject.FolderExists:
If Not fso.FolderExists(uncFolder) Then
MsgBox "SharePoint folder not found. Cannot connect to folder, or folder does not exist. SharePoint URL required for report: """ & uncFolder & """", vbCritical, "Folder not found"
GoTo exitHandler
End If
问题是这不能可靠地工作。如果用户以无线方式连接或第一次连接到文件夹,则最多可能需要五秒钟才能连接,进行身份验证和打开。 FolderExists函数可以在此之前超时并返回假阴性。
是否有可靠的方法来确保用户能够连接?我使用优秀的DoCmd.OutputTo acReport ... acFormatPDF来自动打印多个报告并将它们保存到SharePoint。但我必须确保用户能够在尝试打印并保存之前进行连接。
谢谢!
答案 0 :(得分:1)
不确定,但这可能有用..尝试使用xmlhttp对象读取页面,这应该等待状态...设置对Microsoft XML的引用,或者如果您愿意,则为latebind ...
Function TestURL(url As String) As Boolean
On Error GoTo errhandler
Dim httpObject As New XMLHTTP
With httpObject
.Open "GET", url, False
.send
If .ReadyState = 4 And .Status = 200 Then TestURL = True
End With
Set httpObject = Nothing
Exit Function
errhandler: Debug.Print "TestURL", Err.Description
End Function
所以你可以检查,并在必要时继续检查,直到这个函数返回true,如果需要,你可以在开始导出之前睡觉...
答案 1 :(得分:0)
Sharepoint是文件系统上的一个HTML表单层,可以将Sharepoint使用的URL转换为常规的Windows文件系统地址。
所以你需要这样的东西:
sFolderPath = TidyFilePath(SharepointFolderURL)并且对Scripting.FileSystemObject进行普通调用以检查结果:
这里是URL翻译器......
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.FolderExists(sFolderPath)
Public Function TidyFilePath(strPath As String) As String ' Translate file paths from sharepoint into WinFS paths我确信有人在某个地方发布了一个权威的翻译器,它可以捕获所有需要的HTML实体,以便将Windows网络路径转换为valiod URL。它可能存在于System32的一个库中,只要我知道在哪里看......
strPath = Trim(strPath)
strPath = Replace(strPath, "/", "/") strPath = Replace(strPath, "%2F", "/") strPath = Replace(strPath, "/", "\") strPath = Replace(strPath, "\", "\") strPath = Replace(strPath, "%5C", "\") strPath = Replace(strPath, "%20", " ") strPath = Replace(strPath, " ", " ") strPath = Replace(strPath, " ", " ") strPath = Replace(strPath, "%A0", " ") strPath = Replace(strPath, Chr(160), " ") strPath = Replace(strPath, "<", "") strPath = Replace(strPath, ">", "")
If Left(strPath, 7) = "http:\" Then strPath = Replace(strPath, "http:\", "", 1) ElseIf Left(strPath, 8) = "https:\" Then strPath = Replace(strPath, "https:\", "", 1) ElseIf Left(strPath, 6) = "ftp:\" Then strPath = Replace(strPath, "ftp:\", "", 1) ElseIf Left(strPath, 7) = "ftps:\" Then strPath = Replace(strPath, "ftps:\", "", 1) End If
TidyFilePath = strPath
End Function
......任何.NET和Ruby开发人员都会摸不着头脑 * 并想知道&#34; 那是什么呢?这怎么可能是一个问题呢?&#34;因为大多数现代语言都是在你从未见过甚至想过的层面上为你做这一切的。
*通过仔细选择单词,我避免了对头与开发人员比例的不礼貌假设。我们仍然无法弄清楚他们在哪里留下了巨大的脑子。