在尝试将范围导出为在userform上使用的图片时,我有以下内容:
FolderPath = ThisWorkbook.Path & "\dbfiles"
If ComboBox3.Value = "Cube" Then
With Worksheets("Form")
Set r = .Range("AE21:AM52")
r.CopyPicture Appearance:=xlPrinter, Format:=xlPicture
Set chtO = .ChartObjects("Chart 4")
End With
With chtO.Chart
.Paste
.Export Filename:=FolderPath & "\temppic.bmp", FilterName:="BMP"
End With问题是,当代码运行并且图表区域中已经有一张图片时,“新粘贴”的大小是不同的,并且不会填充图表区域。我需要这样做,所以图片与我的用户表单上的其他对象一致。我发现,如果我手动删除图片,但留下图表(单击,按删除),一切正常。所以我的问题是,你是如何务实地做到这一点的?我已经尝试过.delete,在那里的差距是无效的。(删除object_chart失败的方法)预先感谢。
发布于 2016-03-14 17:32:00
With chtO.Chart
Do While .Shapes.Count > 0
.Shapes(1).Delete
Loop
.Paste
.Export Filename:=FolderPath & "\temppic.bmp", FilterName:="BMP"
End Withhttps://stackoverflow.com/questions/35993811
复制相似问题