Download instead of open (display) files using IE

Pegaso

New member
Joined
May 12, 2015
Messages
1
Reaction score
0
Points
0
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:


Code:
'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


Sheets("Summary").Activate


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!
    Do
    If IE.ReadyState = 4 Then
    IE.Visible = False 'True 'False
    Exit Do
    Else


    DoEvents
    End If
    Loop


    IE.Quit
    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:




sevenforums.com/browsers-mail/369669-download-instead-open-display-files.html#post3064546
techsupportforum.com/forums/f56/download-instead-of-open-display-files-using-ie-993874.html#post6300994
mrexcel.com/forum/excel-questions/854594-download-instead-open-display-files-using-ie.html#post4155709
ozgrid.com/forum/showthread.php?t=194709&p=745801#post745801


Any help is highly appreciated!




Warmest regards




Pegaso
 
Nothing thrilling:

Code:
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, "http://www.google.com/intl/en/images/logo.gif", "G:\OF\GoogleLogo.gif", 0, 0
End Sub
 
Back
Top