我试图登录公司跟踪网站并从C驱动器中的文件下载文档,同时打开从C驱动器中下载的文档时,出现错误
Adobe Reader无法打开pdf,因为它不是受支持的文件类型,或者因为文件已损坏
您能建议从网站下载PDF文件吗?
Option Explicit
#If VBA7 Then
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" ( _
ByVal pCaller As LongPtr, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As LongPtr, _
ByVal lpfnCB As LongPtr) As LongPtr
#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
Sub DowloadSingleFile()
Dim FileURL As String
Dim DestinationFile As String
FileURL = "https://expo.expeditors.com/expotr/expotr?action=com.expd.webapp.tracking.action.document.DocumentImageDownloadWebAction&Type=Image.Get&xref=IVP9OABdjwlQyfAP4d8VNzKeBtYse1TlCWJmb5gzyMxbwbgxBLP19w%3D%3D"
DestinationFile = "C:\VBA\4750422330.pdf"
If URLDownloadToFile(0, FileURL, DestinationFile, 0, 0) = 0 Then
Debug.Print "file download started"
Else
Debug.Print "file download not started"
End If
End Sub