Download an Excel file from SharePoint

Naimishforu
Posted by Naimishforu under VB.NET category on | Points: 40 | Views : 5295

Sub DownloadExcelDocumentFromSP(ByVal documentURL As String, ByVal savePathWithFileName As String)
Dim objExl As New Excel.Application()
With objExl
.DisplayAlerts = False
.Visible = False
With .Workbooks.Open(documentURL)
.SaveAs(savePathWithFileName)
.Close()
End With
.Quit()
End With
If objExl IsNot Nothing Then
Marshal.ReleaseComObject(objExl)
Marshal.ReleaseComObject(objExl)
End If
objExl = Nothing
End Sub

Comments or Responses

Login to post response