我使用以下内容在单元格中插入图像并使用该单元格调整大小。但是,当我将其发送给无法访问该驱动器的人时,它会链接到我的链接图像无法显示错误'。我想打破'此链接并将文档保存在文档中。我已经读过我需要使用形状而不是图像,但我正在努力使这个工作。你能帮我吗?谢谢。
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
答案 0 :(得分:0)
尝试:
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