Help adjust strsave = strsavepath vba

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!
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Watch MrExcel Video

Forum statistics

Threads
1,123,504
Messages
5,602,057
Members
414,498
Latest member
jordanmiller7890

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top