我可以成功浏览并在所选单元格中插入图像,并根据需要调整其大小。问题是当我将 excel 文件通过电子邮件发送给 asscoiates 时,图像不显示,因为图像文件的路径不在他们的电脑上。这是我正在使用的代码,使用键盘快捷键 Ctrl-i 调用它:
Public Sub InsertAndResize()
CellWidth = Selection.Width
CellHeight = Selection.Height
CellLeft = Selection.Left
CellTop = Selection.Top
ActiveSheet.Pictures.Insert( _
Application.GetOpenFilename( _
"JPG picture files (*.jpg),*.jpg", , "Select the picture")).Select
Selection.ShapeRange.Width = CellWidth
If Selection.ShapeRange.Height > CellHeight Then Selection.ShapeRange.Height = CellHeight
With Selection
.Height = Selection.ShapeRange.Height - 4
.Width = Selection.ShapeRange.Width - 4
.Left = CellLeft + ((CellWidth - .Width) / 2)
.Top = CellTop + ((CellHeight - .Height) / 2)
End With
End Sub
如何将图像插入/粘贴到单元格中并消除或断开指向源文件的链接,以便其他人在打开文件副本时可以看到它?
在此先感谢您的任何建议。史蒂夫