VBA从SharePoint文件夹打开特定的Excel文件

我想打开存储在我的SharePoint下的文件夹的Excel文件

//文档//devise// Excel //items.xlsx

我通过互联网search,并提出了下面的代码。 代码的问题是打开本地驱动器中的“文件打开”对话框。

任何人都可以,build议我一个代码,我可以使用,并可以从SharePoint打开Excel文件

这是我试过的,前面的例子在论坛中试过

Sub Share() Dim S As Workbook Dim WB As Variant With Application.FileDialog(msoFileDialogOpen) .InitialFileName = "https://Sharepoint.de/Content/0030/default.aspx" & "/RootFolder=%2Fcontent%2F00008200%2FTeam%20Documents%2F02%20%2D%20Design%2F0001%20Design%2FExcel&FolderCTID=0x01200083BC38D90EC5674491B520CC48282737&View={28035ED9-59EF-42BE-BA4B-A36193C54539}&InitialTabId=Ribbon%2EDocument&VisibilityContext=WSSTabPersistence" .AllowMultiSelect = False .show For Each WB In .SelectedItems Set S = Workbooks.Open(WB) Next End With If S Is Nothing Then Exit Sub End Sub 

提前感谢你

这篇文章很好地涵盖了你的问题。 访问文件系统(包括networking)中的文件:

此方法打开某个工作簿:

 Workbooks.Open ("yourWorkbook.xls") 

文档和这个方法的例子 。

如果你真的想打开文件夹,你可以使用这个:

 Application.FollowHyperlink "FolderLocation" 

此方法的文档 。

编辑:

如本文所述,使用UNCpath。 将您的文件名添加到path并使用上面的方法访问它。

您可以使用简单的Debug.Print f.Name文章中示例代码中的Cells(RowCtr, 1).Value = f.Name Debug.Print f.Name来检查结果。