所以我有一个分配给命令按钮的宏。按下它会打开一个对话框供用户导入图片文件。然后它调整图像的大小并将其放在特定的单元格上。但是如果我移动原始图片文件的位置,图像在 Excel 中就会消失。有没有机会我可以将它保存在 excel 文件中,这样如果我移动原始文件位置就无关紧要了。
代码如下:
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