Sub 批量插入嵌入图片()
On Error Resume
Next
Dim C As Range, i As
Integer
Sheets("联合分析").Select
If
ActiveSheet.ChartObjects.Count > 0 Then
ActiveSheet.ChartObjects.Delete '批量删除图表
For Each C In
Range("C7:E7")
Cells(C.Row - 1,
C.Column).Select
ActiveSheet.Pictures.Insert("D:\指定目录\" & C.Value &
".png").Select
Selection.Placement =
xlMoveAndSize
Selection.ShapeRange.Height = 245
Selection.ShapeRange.Width = 375
Application.CommandBars("Format Object").Visible = False
Next
'让图片适应单元格()
Dim sh As Shape
'声明图形对象变量
For Each sh In
ActiveSheet.Shapes '遍历本表所有图形对象
sh.LockAspectRatio = False
'让图片可以高度、宽度分别调整,即不锁定长款比
sh.Left = sh.TopLeftCell.Left
'调整左边距
sh.Top = sh.TopLeftCell.Top '调整上边距
sh.Width =
sh.TopLeftCell.Width '调整宽度
sh.Height = sh.TopLeftCell.Height '调整高度
Next sh
End Sub
加载中,请稍候......