我可以成功浏览并在所选单元格中插入图像,并根据需要调整大小。问题是当我通过电子邮件将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
如何将图像插入/粘贴到单元格中并消除或断开源文件的链接,以便其他人在打开文件副本时可以看到它?
提前感谢任何建议。 史蒂夫