从SharePoint下载XLSM文件
我正在使用解决方案的代码
它在我的目标文件夹上生成一个文件,但我无法使用它。它似乎是腐败的。
我是否将文件链接到错误下载?
还是该问题是XLSM文件未设计的XLSM文件?
Option Explicit
#If VBA7 Then
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
#Else
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
#End If
Function DownloadFileFromWeb(strURL As String, strSavePath As String) As Long
' strSavePath includes filename
DownloadFileFromWeb = URLDownloadToFile(0, strURL, strSavePath, 0, 0)
End Function
Sub GetFile()
Dim urlName As String
urlName = "https://talanx.sharepoint.com/:x:/r/sites/LiabilityGlobalRisk/_layouts/15/Doc.aspx?sourcedoc=%7BC39E3D22-D263-4519-B6A5-33B64496F6E0%7D&file=Test.xlsm&action=default&mobileredirect=true"
Dim fName As String
fName = "J:\TEST\Test.xlsm"
URLDownloadToFile 0, urlName, fName, 0, 0
End Sub
I am using the codes provided by Solution to download sharepoint xlsx
It generates a file on my destination folder, but I am not able to use it. It seems to be corrupt.
Do I link the file to download wrongly?
Or is the issue an xlsm file for which the code was not designed?
Option Explicit
#If VBA7 Then
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
#Else
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
#End If
Function DownloadFileFromWeb(strURL As String, strSavePath As String) As Long
' strSavePath includes filename
DownloadFileFromWeb = URLDownloadToFile(0, strURL, strSavePath, 0, 0)
End Function
Sub GetFile()
Dim urlName As String
urlName = "https://talanx.sharepoint.com/:x:/r/sites/LiabilityGlobalRisk/_layouts/15/Doc.aspx?sourcedoc=%7BC39E3D22-D263-4519-B6A5-33B64496F6E0%7D&file=Test.xlsm&action=default&mobileredirect=true"
Dim fName As String
fName = "J:\TEST\Test.xlsm"
URLDownloadToFile 0, urlName, fName, 0, 0
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论