2013-02-01 62 views
1

我可以成功浏览并在所选单元格中插入图像,并根据需要调整其大小。问题是,当我通过电子邮件发送excel文件给asscoiates时,图像不显示,因为图像文件的路径不在他们的pc上。这里是我使用的代码,调用它用键盘快捷键Ctrl-I:粘贴图像excel

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 

如何插入/图片粘贴到一个细胞,消除或断开链接到源文件,以便其他人可以当他们打开文件的副本时看到它?

在此先感谢您的任何建议。 史蒂夫

+0

使用'worksheet.shapes.addPicture()'方法,而不是清理从image links片'Pictures.Insert()'。将'LinktoFile'设置为False,将'SaveWithDocument'设置为True。 –

+0

哦,有可能重复'http:// stackoverflow.com/questions/9609631 /删除路径从文件名称的图片在vba' – bonCodigo

回答