Guys,
Please find the code used in the tutorial 'Downloading Files from the Internet from VBA Simplified Series' below. If you have any questions please feel free to comment below the video or write to privately at vbaa2z.team@gmail.com and I will try and come back as soon as possible. Please do not forget to leave a like and subscribe to our channel.
Tutorial link: https://youtu.be/H4-w6ULc_qs
Option Explicit 'Tutorial link: https://youtu.be/H4-w6ULc_qs #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 download_file() '----------------------------- 'Thanks for downloading the code. 'Please visit our channel for a quick explainer on how to use this code. 'Feel free to update the code as per your need and also share with your friends. 'Download free codes from http://vbaa2z.blogspot.com 'Support our channel: youtube.com/vbaa2z 'Author: L Pamai (vbaa2z.team@gmail.com) '----------------------------- Dim downloadStatus As Variant Dim url As String Dim destinationFile_local As String url = [D3] destinationFile_local = "C:\Users\LP\Downloads\" & fileName([D3]) downloadStatus = URLDownloadToFile(0, url, destinationFile_local, 0, 0) If downloadStatus = 0 Then MsgBox "Downloaded Succcessfully!" Else MsgBox "Download failed" End If End Sub Function fileName(file_fullname) As String fileName = Mid(file_fullname, InStrRev(file_fullname, "/") + 1) End Function
No comments:
Post a Comment
Note: only a member of this blog may post a comment.