Excel VBA 调整图片高度宽度等于所在单元格高度宽度

2019-04-15 13:37发布


'调整图片高度宽度等于单元格高度宽度 Sub setpic()
Dim Pic As Shape
    For Each Pic In Sheet5.Shapes
        Pic.LockAspectRatio = msoFalse
        Pic.Top = Pic.TopLeftCell.Top
        Pic.Left = Pic.TopLeftCell.Left
        Pic.Height = Pic.TopLeftCell.Height
        Pic.Width = Pic.TopLeftCell.Width
    Next
End Sub ----------------------------------------------------------------------------
Sub setpic1()
Dim p As Shape, d$
  For Each p In Sheet5.Shapes
    p.LockAspectRatio = msoFalse
    d = p.TopLeftCell.Address
    p.Height = Range(d).Height
    p.Width = Range(d).Width
    p.Top = Range(d).Top
    p.Left = Range(d).Left
  Next
End Sub