Excel VBA 根据合并单元格大小调整图片大小

2019-04-15 13:27发布

Sub adjustpic()  '根据合并单元格大小调整图片大小
Dim Pic As Shape
For Each Pic In ActiveSheet.Shapes
   If Pic.TopLeftCell.MergeCells = True Then
        Set cc = Pic.TopLeftCell.MergeArea
        Pic.LockAspectRatio = msoFalse
        Pic.Top = cc.Top + 5
        Pic.Left = cc.Left + 5
        Pic.Height = cc.Height - 10
        Pic.Width = cc.Width - 10
    End If
Next
End Sub