Image 在单元格中插入图片的宏将创建一个链接,该链接将导致';链接图像无法显示';错误

Image 在单元格中插入图片的宏将创建一个链接,该链接将导致';链接图像无法显示';错误,image,vba,excel,Image,Vba,Excel,我正在使用下面的命令在单元格中插入图像,并使用该单元格调整大小。但是,当我将其发送给无法访问其链接到的驱动器的人时,我会得到“链接图像无法显示错误”。我想'打破'这个链接,并保存在文件中的图片。我曾读到我需要使用形状而不是图像,但我正在努力让它发挥作用。你能帮忙吗?谢谢 Sub InsertPicture() Dim sPicture As String, pic As Picture sPicture = Application.GetOpenFilename _ ("Pictures

我正在使用下面的命令在单元格中插入图像,并使用该单元格调整大小。但是,当我将其发送给无法访问其链接到的驱动器的人时,我会得到“链接图像无法显示错误”。我想'打破'这个链接,并保存在文件中的图片。我曾读到我需要使用形状而不是图像,但我正在努力让它发挥作用。你能帮忙吗?谢谢

Sub InsertPicture()
 Dim sPicture As String, pic As Picture

 sPicture = Application.GetOpenFilename _
 ("Pictures (*.gif; *.jpg; *.bmp; *.tif), *.gif; *.jpg; *.bmp; *.tif", _
 , "Select Picture to Import")

 If sPicture = "False" Then Exit Sub

 Set pic = ActiveSheet.Pictures.Insert(sPicture)
 With pic
 .ShapeRange.LockAspectRatio = msoFalse
 .Height = ActiveCell.Height
 .Width = ActiveCell.Width
 .Top = ActiveCell.Top
 .Left = ActiveCell.Left
 .Placement = xlMoveAndSize
 End With

 Set pic = Nothing

 End Sub
尝试:

尝试:


试着用。嗨,法迪。我已经试过了,但是我无法解决如何调整代码。我已经尝试了几十次迭代,在谷歌上搜索了大量的例子,但我一直在调试。试着使用。嗨,Fadi。我已经试过了,但是我无法解决如何调整代码。我已经尝试了几十次迭代,在谷歌上搜索了很多例子,但我一直在调试。非常感谢@fadi的帮助。这正是我想要它工作的方式。我把事情弄得更复杂了。非常感谢你的帮助@fadi。这正是我想要它工作的方式。我让事情变得比需要的更复杂。
Sub InsertPicture()
     Dim sPicture As String

     sPicture = Application.GetOpenFilename _
     ("Pictures (*.gif; *.jpg; *.bmp; *.tif), *.gif; *.jpg; *.bmp; *.tif", _
     , "Select Picture to Import")

     If sPicture = "False" Then Exit Sub

     Dim Rng As Range: Set Rng = ActiveCell


     ActiveSheet.Shapes.AddPicture(sPicture, msoFalse, msoTrue, _
       Rng.Left, Rng.Top, Rng.Width, Rng.Height).Placement = xlMoveAndSize

 End Sub