I have an Excel workbook (Excel 2013, Windows 10) containing a column of paths to jpg files on my computer (column "B") and I'd like to have a macro which will work through all of the rows inserting a thumbnail of the picture into the cell to the left of the path, ie in column "A".
I'm no macro VBA coder and usually record macros close to what I want and then edit the code it records for me. So I know that I can write a macro which simply records me doing this and the macro runs. However when I try to generalise it, I get an error, although the error is on the same line as ran fine previously.
So, this macro works -
Sub Macro1()
'
' Macro1 Macro
'
Range("A4").Select
ActiveSheet.Pictures.Insert("D:\My Documents HDD\...(path)...\Filename.jpg").Select
End Sub
However this doesn't work -
Sub Insert_picture_from_URL()
'
' Insert_picture_from_URL Macro
'
Dim i As Long, v As String, w As String
For i = 1 To 200
v = ("B" & i)
w = ("A" & i)
Range(w).Select
ActiveSheet.Pictures.Insert(v).Select
Next i
End Sub
I get "Run-time error '1004': Unable to get the Insert property of the Pictures class"
Please can you tell me where I'm going wrong? I realise I'll need to add code to resize the thumbnails to a reasonable size, but I need to get this to work first.
Thanks.