title: vba Insert jpg to specific cells by matching cell value with image name
body: <p>I've looked around on a few different ways to insert .jpg by a macro and there seem to be few, but some different ways. I tried to follow <a href="http://ccm.net/faq/6485-excel-a-macro-to-insert-pictures" rel="nofollow">this</a> helpful guide, but are unsuccessful. </p>
  
  <p>MY macro doesn't find the image location. I want the macro to look for images saved in a folder named "Pictures" in the same location the current workbook, compare it to references in column A and insert in column B if match.</p>
  
  <p>I get this error message: "Unable to get the insert property of the Pictures class." Does mean my link is wrong?</p>
  
  <p>As you can see (<a href="http://i.stack.imgur.com/yY5VJ.png" rel="nofollow">Worksheet</a>) my references are in Column A, starting at A7, but I have merged cells(A7:A16), so the next reference is in A18, A29.. etc. 
  ex.</p>
  
  <p>Any help appreciated. Thanks.</p>
  
  <pre><code>Sub ImageMacro()
  
  'Used to import picture files from a pre-sorted file. (Each picture must have a unique name, duplicates removed).
  
  'Sub Picture()
   Dim picname As String
   Dim pasteAt As Integer
   Dim lThisRow As Integer
  
      lThisRow = 7
  
      Do While (Cells(lThisRow, 1) &lt;&gt; "")
  
          'Range("B7").Select 'This is where picture will be inserted
          pasteAt = Cells(lThisRow, 2)
        '  Cells(pasteAt, 2).Select 'This is where picture will be inserted (IS THIS A DUPLICATE OF ABOVE?)
  
          'Dim picname As String
          'picname = Range("A7") 'This is the picture name
           picname = Cells(lThisRow, 1) 'This is the picture name
  
          ActiveSheet.Pictures.Insert("smb://pnld-svr-02._smb._tcp.local/Business Administration/Staff Folders/Ida Moe Evensen/0000 Templates/Pictures/" &amp; picname &amp; ".jpg").Select 'Path to where pictures are stored
          '''''''''''''''''''''''''''''''''''''''''''''''''''''''
          ' This resizes the picture
          '''''''''''''''''''''''''''''''''''''''''''''''''''''''
          With Selection
              '.Left = Range("A6").Left
              '.Top = Range("A6").Top
              .Left = Cells(pasteAt, 1).Left
              .Top = Cells(pasteAt, 1).Top
  
              .ShapeRange.LockAspectRatio = msoFalse
              .ShapeRange.Height = 100#
              .ShapeRange.Width = 80#
              .ShapeRange.Rotation = 0#
          End With
  
          lThisRow = lThisRow + 11
  
      Loop
  
      Application.ScreenUpdating = True
  
      Exit Sub
  
  ErrNoPhoto:
      MsgBox "Unable to Find Photo" 'Shows message box if picture not found
      Exit Sub
  
  
  End Sub
  </code></pre>