troubleshooting Question

Website download adobe reader could not open PDF because it is either not a supported file type or because the file has been damaged

Avatar of Suman Devadiga
Suman DevadigaFlag for India asked on
VBA
8 Comments1 Solution140 ViewsLast Modified:
Hello Team,

Am trying to login company tracking website and download documents from file in C drive, while opening downloaded documents from C drive I am getting error i.e.

Adobe Reader could not open pdf because it is either not a supported file type or because the file has been damaged

Can you advise is there any other way to download PDF file from website?


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

Open in new window

ASKER CERTIFIED SOLUTION
Suman Devadiga

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros