Consulting

Results 1 to 5 of 5

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

  1. #1

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

    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:

    HTML Code:
     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?
    Last edited by Aussiebear; 09-22-2016 at 09:37 AM. Reason: Split presented code

  2. #2
    So, even after I received the runtime error, it appears after opening the excel sheet it still works.
    Please close this thread. So, strange!

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Closing this thread serves no purpose until a solution can be arrived at.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    Quote Originally Posted by Aussiebear View Post
    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.

    pic2.jpg

    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)





    Attached Images Attached Images

  5. #5
    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?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •