0
votes

I am using the below code, to open the Excel file from SharePoint.

I am Little confused how, I should code, for the accessing the file from an Folder in SharePoint.

The Excel file, i Need is stored in ; SharePoint>> Document >> Test >> Data >>July

and the link to my SharePoint is like this, https://forum/content/008200/default.aspx?RootFolder=%2Fcontent%2F00008200%20Documents%2DTest%2F0001%20%29&FolderCTID=0x01200083BC38D90EC5674491B520CC48282737&View={00112127-0FE6-44A4-A5FB-86BC6C4E835B}&InitialTabId=Ribbon%2EDocument&VisibilityContext=WSSTabPersistence

Could someone help me, How i should code, to acess an Excel file from a Folder in SharePoint.

I have attached a Piece of code, which i reffered it from the Forum. and would be helpful, if you could comment the lines, if you can suggest me a code.

Sub Share()
Dim SWB As Workbook
Dim WB As Variant

With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "https://forum/Content/008200/default.aspx" & "\"
.AllowMultiSelect = False
.show

For Each WB In .SelectedItems
Set SWB = Workbooks.Open(WB)
Next
End With

If SWB Is Nothing Then Exit Sub

End Sub
1

1 Answers

0
votes

i don't know , how can you with vb but i assume your file in Document Library if it is you can use this code to get document.

SPFile myExcelFile = SPContext.Current.Web.GetFile("/Documents/Test/Data/July/excelFile.xslx"); 
Stream excelFileStream = myExcelFile.OpenBinaryStream();