粘贴图像excel

粘贴图像excel,excel,vba,Excel,Vba,我可以成功浏览并在所选单元格中插入图像,并根据需要调整其大小。问题是,当我通过电子邮件将excel文件发送给asscoiates时,图像不会显示,因为图像文件的路径不在他们的电脑上。以下是我正在使用的代码,使用键盘快捷键Ctrl-I调用它: Public Sub InsertAndResize() CellWidth = Selection.Width CellHeight = Selection.Height CellLeft = Selection.Left CellTop = Select

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

提前感谢您的建议。
Steve

您可以通过将图像链接到单元格名称来清除图像链接中的工作表


使用worksheet.shapes.addPicture方法代替Pictures.Insert。将LinktoFile设置为False,并将SaveWithDocument设置为True。哦,可能存在重复http://stackoverflow.com/questions/9609631/remove-path-from-the-file-name-of-a-picture-in-vba