VB Help - Use Image url to insert image and resize (repeat 100 times)

nikkibeak27

New Member
Joined
Jul 14, 2017
Messages
11
Hey, Please help a NON coder,

I need a VB code that does the following;

Sheet 1
Cell C10 - Contains an image url (this can either be a file location or web address)
I need to copy that url and use that to insert picture in cell J10
Once the image is in cell J10 the image width needs to be adjusted to 7cm

then the same process needs to happen for the next row (C11 / J11)

this process must continue for a total of 100 rows i.e. stop at row C110/J110)

I would really appreciate any help !
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
try
Code:
Sub InsertPic()
    Set MyRange = Application.Selection
    For Each c In MyRange
        picStr = c.Value
        c.Offset(0, 1).Select
        Set p = ActiveSheet.Pictures.Insert(picStr)
        p.Width = Int(7 * 26.996626)
        Set p = Nothing
    Next c
End Sub
Select image url's and run . .
 
Last edited:
Upvote 0
Hi,

when I try to run this it takes me to debugging mode with the below section highlighted in yellow

Set p = ActiveSheet.Pictures.Insert(picStr)

stupid q ... is there a section that specifies that the image must be loaded in column J?

Thanks
 
Upvote 0
what was the error-message?
NB I tested only local url . .
NB 2 . . from C to J : use c.offset(0,7) tot put it in the right column
 
Last edited:
Upvote 0
runtime error 1004

note: not all pictures will be available so it will need to do something like on error move to next (gawd I really have NO idea what I'm talking about)
 
Upvote 0
uhmmm ... on error, could I specify a specific url to be used? then move to next row
It would point to a generic pic saying image not available.
 
Upvote 0
i'm not into Error-handlers . . . sorry

test it with proven filenames (i.e. c:\users\Nikki\pic.jpg ) . .
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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
Back
Top