"Linked image cannot be displayed. The file may have been moved, renamed, or deleted." in excel

Hi,

I’m trying to save Excel with images using VBA code. But when moving to other file location images are not displayed…
Can anyone please help?

I’m using VBA code below
Sub InsertImage(ImgPath,cellAdddress,sheetName,imgHeight,imgWidth)

Set ws = Sheets(sheetName)

ws.picture.Insert(imgPath).Select
With Selection
     .Top = ws.Range(cellAddress).Top
     .Left= ws.Range(cellAddress).Left
     .Height= imgHeight
     .Width= imgwidth
End With

End Sub

Thanks!

Hey @koneruupendra111
you can try this solution:

Sub InsertImage(ImgPath As String, cellAddress As String, sheetName As String, imgHeight As Single, imgWidth As Single)
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Sheets(sheetName)

    ws.Shapes.AddPicture Filename:=ImgPath, _
                         LinkToFile:=msoFalse, _
                         SaveWithDocument:=msoTrue, _
                         Left:=ws.Range(cellAddress).Left, _
                         Top:=ws.Range(cellAddress).Top, _
                         Width:=imgWidth, _
                         Height:=imgHeight
End Sub

Thanks alot it working now!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.