插入的图片在Excel中不可见(只有大小的边框)

我在excel中发现/写了一个macros,它允许我在单元格中插入一张图片,以便excel自动将图片与单元格大小相匹配。

Sub InsertAndSizePhoto() Dim sFileName As String Dim oShape As Shape If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub Dim myPath As String Dim folderPath As String folderPath = Application.ActiveWorkbook.Path sFileName = Application.GetOpenFilename( _ FileFilter:="Images (*.gif;*.jpg;*.png), *.gif;*.jpg;*.png", _ FilterIndex:=1, _ Title:="Insert Picture", _ ButtonText:="Insert", _ MultiSelect:=False) If sFileName = "False" Then Exit Sub With ActiveCell.MergeArea ActiveSheet.Shapes.AddPicture _ Filename:=sFileName, _ LinkToFile:=msoFalse, _ SaveWithDocument:=msoTrue, _ Left:=.Left, _ Top:=.Top, _ Width:=.Width, _ Height:=.Height End With End Sub 

有时会插入并安装多个图片,但它们不可见。 当我点击图片时,只有尺寸窗口/边框变得可见。 它们在打印预览中也不可见。 当我以纸张的PDF格式打印文档时,它们是可见的。

当我重新打开工作簿时,照片再次可见。 造成这个问题的原因 如何解决? 在选项中,所有对象都可见。

图片样本

以下是使用Pictures.Insert的示例代码:

 With ActiveSheet.Pictures.Insert(Filename:=sFileName, LinkToFile:=False, SaveWithDocument:=True) .Placement = xlMoveAndSize With .ShapeRange .Height = ActiveCell.MergeArea.Height .Width = ActiveCell.MergeArea.Width .Left = ActiveCell.MergeArea.Left .Top = ActiveCell.MergeArea.Top End With End With