Inserting Picture From URL Is Pasting Into ActiveCell Instead Of Variable

Lewzerrrr

Active Member
Joined
Jan 18, 2017
Messages
256
Hi,

I have the following code that pastes an image from a URL into a cell where rngPicPosition is variable, it changes for each loop in my full code so first loop is .cells(5,3) next loop is .cells(10,3).. .cells(10,5) however it's pasting the image into the activecell.

Any ideas why? I'm stumped.

Also, is there a way to skip the With Pic part and when pasting in but still use them measurements?

It pastes in fully on but I want it to paste in rngPicPostion.

Code:
Set Pic = .Parent.Pictures.Insert(URL)

Code:
            Set rngPicPosition = Worksheets(template.Name).Cells(iStartRow, iStartColumn)

                URL = "http://media.topshop.com/wcsstore/TopShop/images/catalog/TS" & .Cells(x, 10) & "_Large_F_1.jpg" '-- URL storing Line No. if not found in directory.   
             
                    With rngPicPosition
                    
                        On Error Resume Next
                    
                        Set Pic = .Parent.Pictures.Insert(URL)
                        
                            With .rngPicPosition
                                Pic.Top = .Top
                                Pic.Left = .Left
                                Pic.Height = .Height
                                Pic.Width = .Width
                            End With
                            
                            With Pic
                                .Top = Pic.Top + 8.7
                                .Left = Pic.Left + 26.1
                                .Width = 92.6929242
                                .Height = 100.629933
                            End With
                        
                        Set Pic = Nothing
                        
                    End With
 
Last edited:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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