+ Reply to Thread
Results 1 to 4 of 4

Excel 2010 "vlookup pictures vba" links image instead of saving it as an image

Hybrid View

  1. #1
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Excel 2010 "vlookup pictures vba" links image instead of saving it as an image

    You must use Shapes.AddPicture rather than Pictures.Insert:
    Sub InsertPictures()
       Dim strPath                     As String
       Dim strFile                     As String
       Dim objPic                      As Shape
       Dim LastRow                     As Long
       Dim i                           As Long
    
       LastRow = Cells(Rows.Count, "A").End(xlUp).Row
    
       If LastRow = 1 Then
          MsgBox "No data is available...", vbInformation
          Exit Sub
       End If
    
       Application.ScreenUpdating = False
    
       strPath = "C:\Users\user\Desktop\"
    
       If Right(strPath, 1) <> "\" Then strPath = strPath & "\"
    
       For i = 2 To LastRow
          strFile = Cells(i, "A").Value & ".jpg"
          If Len(Dir(strPath & strFile, vbNormal)) > 0 Then
             With Cells(i, "B")
                Set objPic = ActiveSheet.Shapes.AddPicture(Filename:=strPath & strFile, linktofile:=msoFalse, _
                                                           savewithdocument:=msoCTrue, Left:=.Left, _
                                                           Top:=.Top, Width:=.Width, Height:=.Height)
                objPic.LockAspectRatio = msoFalse
             End With
          Else
             Cells(i, "B").Value = "N/A"
          End If
       Next i
    
       Application.ScreenUpdating = True
    
    End Sub

  2. #2
    Registered User
    Join Date
    11-25-2013
    Location
    lille
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Excel 2010 "vlookup pictures vba" links image instead of saving it as an image

    Oh thank you very much it works perfectly!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 07-17-2013, 12:12 PM
  2. Extract and display image URL from "Linked image cannot be displayed" pictures
    By apyken in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-12-2013, 09:52 PM
  3. Replies: 2
    Last Post: 05-12-2013, 09:51 PM
  4. excel 2010 VBA InsertPicInRange only makes shortcut to image instead of copy of image
    By ArjanSpit in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-10-2012, 02:57 PM
  5. Replies: 1
    Last Post: 08-03-2006, 08:00 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1