简体   繁体   English

VBA从共享点文件夹中打开特定的Excel文件

[英]VBA to open a particular excel file from an sharepoint folder

I want to open an Excel file which is stored in my SharePoint under the Folder 我想打开一个Excel文件,该文件存储在我的SharePoint中的“文件夹”下

//Documents // Design //Excel //items.xlsx //文档//设计// Excel //items.xlsx

I searched through Internet and came up with the below code. 我通过Internet搜索,并想到了以下代码。 The Problem with the code is it is opening the "File open " Dialogue box in the local drive. 代码的问题是它正在打开本地驱动器中的“文件打开”对话框。

Can anyone, suggest me a code that I could work with and could open an Excel file from SharePoint 任何人都可以向我建议可以使用的代码,并可以从SharePoint打开Excel文件

Here is what i tried, with the previous example tried in the Forum 这是我尝试过的,上面的示例在论坛中尝试过

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

Thanking you in advance 预先谢谢你

This SO article covers your question quite well. 这篇SO文章很好地涵盖了您的问题。 To access files within your filesystem (including network): 要访问文件系统(包括网络)中的文件:

This method opens a certain workbook: 此方法打开某个工作簿:

Workbooks.Open ("yourWorkbook.xls")

Documentation and examples for this method. 此方法的文档示例

If you actually want to open the folder, u can use this: 如果您确实要打开文件夹,则可以使用以下命令:

Application.FollowHyperlink "FolderLocation"

Documentation for this method. 此方法的文档

Edit: 编辑:

Use the UNC path as described in This SO article. 在描述使用UNC路径 SO文章。 Add your file name to the path and access it with the methods from above. 将文件名添加到路径中,并使用上述方法访问它。

You can substitute the Cells(RowCtr, 1).Value = f.Name from the sample code in the article with a simple Debug.Print f.Name to check the outcome. 您可以用简单的Debug.Print f.Name本文示例代码中的Cells(RowCtr, 1).Value = f.Name Debug.Print f.Name来检查结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM