PDA

View Full Version : Run time Error 1004 - Unable to get the Picture Class..(Inserting URL images)



leftysgirl
09-22-2016, 07:17 AM
Run time Error 1004 - Unable to get the Picture Class..(Inserting URL images into Excel using Office 365)

Hello,

I am trying to extract from column V (Image URL link) to column W (Blank) the image from the url. Which solely is an image URL.

I have found many snippets of code using, I think what is called VBA Macros to do this function, but I am receiving a runtime error,
Unable to get the Picture Class..

Sub InstallPictures()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim url_column As Range
Dim image_column As Range
'column with url...
Set url_column = Worksheets(1).UsedRange.Columns("V")
'column where image will be inserted
Set image_column = Worksheets(1).UsedRange.Columns("W")
Dim i As Long
For i = 2 To url_column.Cells.Count
Set Picture = image_column.Worksheet.Pictures.Insert(url_column.Cells(i).Value)
Picture.Left = image_column.Cells(i).Left
Picture.Top = image_column.Cells(i).Top
Picture.Height = 40
image_column.Cells(i).EntireRow.RowHeight = 40
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub


I believe this may be part of the issue as the debugger suggested:


Set Picture = image_column.Worksheet.Pictures.Insert(url_column.Cells(i).Value)

This is pretty cool stuff. I just need it to work :)

Any suggestions?

leftysgirl
09-22-2016, 07:23 AM
So, even after I received the runtime error, it appears after opening the excel sheet it still works.
Please close this thread. So, strange!

Aussiebear
09-22-2016, 06:18 PM
Closing this thread serves no purpose until a solution can be arrived at.

leftysgirl
09-26-2016, 12:05 PM
Closing this thread serves no purpose until a solution can be arrived at.
I understand. I thought I was supposed to request it closed, but I am glad it did not. I am still in the same scenario without a solution, and unfortunately I do not have a solution to share ---and still need some advice.

I have tried several variations of codes like the one above, but I still receive the "Run time Error 1004 - Unable to get the Picture Class.."

Here's a pic of my excel sheet. I do have some pictures already uploaded to my column when I thought I had the VBA bug corrected. So, I'm not sure if having some pictures in place already is an issue or having blank lines with no urls.

17182

Also, in the code, there's a section that says, "Set url_column = Worksheets(1)." Is Worksheets(1) supposed to be my spreadsheet's file name? I tried to fiddle with that, but no luck.

The debugger keeps pointing to this line: Set Picture = image_column.Worksheet.Pictures.Insert(url_column.Cells(i).Value)

leftysgirl
09-26-2016, 12:36 PM
It looks the images duplicated over the same cells when I was testing variations of that code. Does anyone know how I can remove them to start fresh?