mtthompsons
asked on
Get images from the URL's in excel
Hi All,
Attached file is a sample. I have the URL's in Column "C" which are of images. I want help with a macro that can check the URL and fetch the images and paste into column "D"
Can anyone help me please as i have 100's to be gathered
Thanks
Sample.xls
Attached file is a sample. I have the URL's in Column "C" which are of images. I want help with a macro that can check the URL and fetch the images and paste into column "D"
Can anyone help me please as i have 100's to be gathered
Thanks
Sample.xls
be reminded you need to have c:\temp directory to save the image locally, otherwise change it to other directory you want on VBA
Duncan
Duncan
ASKER
I want the images into the excel in Column "D" not just download to a drive
Will this code do that?
Will this code do that?
Please review the code , you also need to know what is doing on each code
Duncan
Duncan
ASKER
I get the item with the specified name is not found
I do have a folder called temp in C Drive
When debug goes to this line
ActiveSheet.Shapes("Pictur e 1").Select
I do have a folder called temp in C Drive
When debug goes to this line
ActiveSheet.Shapes("Pictur
it might be you did not select sheet and cell so that there is not Activate
put those two code into test()
ActiveWorkbook.Sheets("she et1").Acti vate
ActiveWorkbook.Sheets("she et1").Rang e("D1").Se lect
Duncan
put those two code into test()
ActiveWorkbook.Sheets("she
ActiveWorkbook.Sheets("she
Duncan
Sub test()
Dim tmp, i As Integer
Dim slocalfile As String
'Delete all image
Dim Pic As Object
For Each Pic In ActiveSheet.Pictures
Pic.Delete
Next Pic
ActiveWorkbook.Sheets("sheet1").Activate
ActiveWorkbook.Sheets("sheet1").Range("D1").Select
'import image
tmp = Range(Range("C1"), Range("C65535").End(xlUp)).Count
Debug.Print "Starting loading and importing image"
For i = 1 To tmp
Debug.Print Cells(i, 3).Value
slocalfile = "C:\temp\" & i & ".png"
Call URLDownloadToFile(0&, Cells(i, 3).Value, slocalfile, 0&, 0&)
Cells(i, 4).Select
Selection.ClearContents
ActiveSheet.Pictures.Insert(slocalfile).Select
Next i
End Sub
I work because I click the Range("D1') in sheet1 before macro start to run
Duncan
Duncan
ASKER
I ran the macro called Test and selected sheet 1 column "D" but all images are being collected but all one over the other in column "A"
just run the attachment , by click atl-F11 go to VBA on Excel and run test() macro and no need to do any select( it is already done for you).
review all my previous post and think about each code function
Duncan
image.xls
review all my previous post and think about each code function
Duncan
image.xls
Please read it, Tutorial for Excel VBA for activate and select at
http://msdn.microsoft.com/en-us/library/office/aa221576(v=office.11).aspx
http://msdn.microsoft.com/en-us/library/office/aa221576(v=office.11).aspx
ASKER
Thanks
Everything works fine
its just that it copies all images on each other and not d column
Please see the attachment
Sample.JPG
Everything works fine
its just that it copies all images on each other and not d column
Please see the attachment
Sample.JPG
probaby it is Excel version issue , I am using 2003
you are using 2007 or above, right ?
you are using 2007 or above, right ?
ASKER
yes i am using 2007
I am downloading Excel 2007, please wait since it is expired
Duncan
Duncan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot for the help...
run the macro1 test() as follows, and save image files at C;\temp\
Hope understand your question.if not, please point it out
Duncan
Open in new window