Results 1 to 2 of 2

Thread: Download instead of open (display) files using IE

  1. #1

    Download instead of open (display) files using IE

    Register for a FREE account, and/
    or Log in to avoid these ads!

    Dear All,

    I have a list of URLs, each one links to a document (.doc, .docx, .bmp, .jpg, etc.). The database is not located locally, and the only way to access the stored data is through the previously mentioned URLs.

    Each time I open a link, IE displays the document instead of downloading it. How can I change that behavior in IE? I need the files to be downloaded instead of opened. The huge amount of files (>10000) makes it impractical to save each document manually.

    A possible solution (I would need help to implement it), would be to use a virtual pdf printer (PDF Creator for instance), to save the file as a .pdf, but this has to be automated as well, due to the high volume of files.

    The code I have so far (!!!a million thanks to Vladimir, ZVI; for helping in develop the code that allowed me to download >100000 non-pdf files!!!), works fine with .pdf files but not with the rest:

    'Creates the links to access the files in each vault
    'Opens each external link, creates a list with all the files and local links for each one
    Sub MainOne() 'Get Vault's URL using IE
    VaultMin = Cells(2, 2)
    VaultMax = Cells(2, 4)
    PathVault = Cells(3, 6)
    u = 0
    For t = VaultMin To VaultMax
        'Section 1 of 3: Read data, creates vault URL, open, extract HTML code
        Cells(2, 3) = t
        NameVault = "HTML-" & t & ".txt"
        Url = Cells(2, 6)
        Set IE = CreateObject("internetexplorer.application")
        IE.Navigate Url
        'Wait for page to load!
        If IE.ReadyState = 4 Then
        IE.Visible = False 'True 'False
        Exit Do
        End If
        Set IE = Nothing
    Next t
    End Sub
    I can use any other browser if that fixes my problem.

    By the way, I also posted a similar thread here:

    Any help is highly appreciated!

    Warmest regards


  2. #2
    Conjurer snb's Avatar
    Join Date
    May 2013
    Excel Version
    Nothing thrilling:

    Private Declare Function DownloadWebFile 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
    Sub M_snb()
        DownloadWebFile 0, "", "G:\OF\GoogleLogo.gif", 0, 0
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts