thelastflame
New Member
- Joined
- May 3, 2012
- Messages
- 14
Hello members,
I need help adjusting the following code to fit my parameters. I provided the entirety of the code, but I believe the change needs to occur at the strURL, strSavePatch, ret portion of the code. Please see below:
Option Explicit
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
Sub Download_from_URL()
Dim wb As Workbook
Dim sh1 As Worksheet
Dim i As Integer
Dim strSavePath As String
Dim strSave As String
Dim strURL As String
Dim ret As Long
Dim url_to_pull
Set wb = ActiveWorkbook
Set sh1 = wb.Sheets("Sheet1")
sh1.Activate
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
If .SelectedItems.Count > 0 Then
strSavePath = .SelectedItems(1)
Else
Exit Sub
End If
End With
url_to_pull = sh1.Range(Cells(1, 1), Cells(sh1.UsedRange.End(xlDown).Row, 1)) ' select all urls in column 1 on sheet 1
For i = 1 To UBound(url_to_pull, 1)
strURL = url_to_pull(i, 1)
strSave = strSavePath & "\" & Right(strURL, Len(strURL) - InStrRev(strURL, "/"))
ret = URLDownloadToFile(0, strURL, strSave, 0, 0)
Next
End Sub
I need the save file path to save the file as the value found in column B.
So something like;
1. look-up url in A1
2. Choose folder path (msoFileDialogFolderPicker)
3. Save jpg from url in A1 as name = value in B1.
loop.
Thanks in advance!
I need help adjusting the following code to fit my parameters. I provided the entirety of the code, but I believe the change needs to occur at the strURL, strSavePatch, ret portion of the code. Please see below:
Option Explicit
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
Sub Download_from_URL()
Dim wb As Workbook
Dim sh1 As Worksheet
Dim i As Integer
Dim strSavePath As String
Dim strSave As String
Dim strURL As String
Dim ret As Long
Dim url_to_pull
Set wb = ActiveWorkbook
Set sh1 = wb.Sheets("Sheet1")
sh1.Activate
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
If .SelectedItems.Count > 0 Then
strSavePath = .SelectedItems(1)
Else
Exit Sub
End If
End With
url_to_pull = sh1.Range(Cells(1, 1), Cells(sh1.UsedRange.End(xlDown).Row, 1)) ' select all urls in column 1 on sheet 1
For i = 1 To UBound(url_to_pull, 1)
strURL = url_to_pull(i, 1)
strSave = strSavePath & "\" & Right(strURL, Len(strURL) - InStrRev(strURL, "/"))
ret = URLDownloadToFile(0, strURL, strSave, 0, 0)
Next
End Sub
I need the save file path to save the file as the value found in column B.
So something like;
1. look-up url in A1
2. Choose folder path (msoFileDialogFolderPicker)
3. Save jpg from url in A1 as name = value in B1.
loop.
Thanks in advance!