Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Login and Download zip files from a url through vba

0

 have an excel file that has multiple records around 5k with urls. I need to go through each record having url and enter it on the browser click on menu->hit download(zip file) and save it on my local folder.

Every time I open this url, it asks for login credentials. I'm not quite sure how to automate this.

However I used URLDownloadToFile declaration.It doesnt seem to work, not sure how to surpass the login page

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
Sub DownloadFileFromWeb()
DownloadFileFromWeb = URLDownloadToFile(0, "http://mouseflow/MyFile.zip", "C:\Temp", 0, 0)
End Sub
Answer
Discuss

Discussion

Dr Liss   Do you expect us to be familiar already with the sub DownloadFileFromWeb? (Plus the functions listed). Does it pass your login credentials to (/press the "enter" on) the webpage?    I'm not familiar so can't help. Hope others are familiar but guess they'd also need to know more to test. 

John_Ru (rep: 6142) Mar 13, '21 at 6:13 am
Add to Discussion



Answer the Question

You must create an account to use the forum. Create an Account or Login