访问SharePoint VBA时出错

我使用Microsoft Scriptime Runtime通过VBA访问客户的SharePoint,以便使用以下SubFunction从存储在一堆SharePoint目录中的Excel工作簿中提取数据。

出于某种原因,我的本地机器(已login到SharePoint)的Sub工作正常,但在其他人的机器上,无法find最后一行的path:

 Set trackerFolder = fs.GetFolder(Parse_Resource(baseDir & trackExtension)) 

作为参考,Excel文件存储在与客户SharePoint不同的networking驱动器上。

有没有人有任何想法, 为什么目录不会填充macros运行在另一个同事的机器上,但工作时,我自己运行? 先谢谢您的帮助!

这是sub(和我的道歉声明variables都在同一行):

 Sub pullData() Dim folder, trackerFolder As folder Dim Fnum As Long Dim f, trackF As File Dim fs As New FileSystemObject Dim FSO As Scripting.FileSystemObject Dim folder2 As Scripting.folder Dim file2 As Scripting.File Dim trackExtension, appExtension, baseDir, FilesInPath, MyFiles(), array_example(), workbookName, trackerName As String Dim i, folderNameInt As Integer Dim folderNames As Variant Dim mybook, trackerBook As Workbook Dim sh, shtrackerAppDataEntry As Worksheet Dim ErrorYes As Boolean Dim intAppRow, totalScriptNum, scratchVar As Integer 'Set counter i = 1 'Name of tracking document trackerName = "Document Latest Macro.xlsm" 'Fill in with all app names, make sure it matches rows in Application Testing Data Entry 'At some point, fill in with app names from Config 'Must match SharePoint app structure folderNames = Array("Folder 1", "Folder 2") 'At some point, put in Config tab the SharePoint file structure appExtension = "Big Dir 1/Big Dir 2/" 'Ditto above baseDir = "https://WEBSITE.sharepoint.com/Integration/Shared Documents/" 'Ditto above trackExtension = "Project Management/" 'Basic Stuff With Application .ScreenUpdating = False .EnableEvents = False .DisplayAlerts = False End With 'Setting variables for tracker book Set trackerFolder = fs.GetFolder(Parse_Resource(baseDir & trackExtension)) 

函数PARSE_RESOURCE是我从另一篇文章中find的(这里是: 从SharePoint网站打开一个Excel文件 ):

 Public Function Parse_Resource(URL As String) 'Uncomment the below line to test locally without calling the function & remove argument above 'Dim URL As String Dim SplitURL() As String Dim i As Integer Dim WebDAVURI As String 'Check for a double forward slash in the resource path. This will indicate a URL If Not InStr(1, URL, "//", vbBinaryCompare) = 0 Then 'Split the URL into an array so it can be analyzed & reused SplitURL = Split(URL, "/", , vbBinaryCompare) 'URL has been found so prep the WebDAVURI string WebDAVURI = "\\" 'Check if the URL is secure If SplitURL(0) = "https:" Then 'The code iterates through the array excluding unneeded components of the URL For i = 0 To UBound(SplitURL) If Not SplitURL(i) = "" Then Select Case i Case 0 'Do nothing because we do not need the HTTPS element Case 1 'Do nothing because this array slot is empty Case 2 'This should be the root URL of the site. Add @ssl to the WebDAVURI WebDAVURI = WebDAVURI & SplitURL(i) & "@ssl" Case Else 'Append URI components and build string WebDAVURI = WebDAVURI & "\" & SplitURL(i) End Select End If Next i Else 'URL is not secure For i = 0 To UBound(SplitURL) 'The code iterates through the array excluding unneeded components of the URL If Not SplitURL(i) = "" Then Select Case i Case 0 'Do nothing because we do not need the HTTPS element Case 1 'Do nothing because this array slot is empty Case 2 'This should be the root URL of the site. Does not require an additional slash WebDAVURI = WebDAVURI & SplitURL(i) Case Else 'Append URI components and build string WebDAVURI = WebDAVURI & "\" & SplitURL(i) End Select End If Next i End If 'Set the Parse_Resource value to WebDAVURI Parse_Resource = WebDAVURI Else 'There was no double forward slash so return system path as is Parse_Resource = URL End If End Function