So I have a macro assigned to a command button. when pressed it opens a dialogue box for user to import a picture file. Then it resizes the image and puts it on a specific cell.
But If I move the original picture file location, the image disappears in Excel. Is there any chance I can save it inside the excel file so that it will not matter if I move the original file location.
The code is as follow:
Sub Add_Image()
Application.ScreenUpdating = False
Range("B18").Select
'varible Picture1 is inserted down below - ***change both***
Picture1 = Application.GetOpenFilename("Picture,*.JPG,Picture,*.JPEG,Picture,*.GIF,Picture,*.BMP")
'edit "("Picture,*.*")" section to add or chanve visible file types
On Error GoTo ErrMsg
ActiveSheet.Pictures.Insert(Picture1).Select
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 145
Selection.ShapeRange.Width = 282
Application.ScreenUpdating = True
Exit Sub
ErrMsg:
MsgBox ("Failed to load Image"), , "Error"
End Sub
.Pictures.Insertdoesn’t seem to provide control over linking or imbedding.However you can use this instead