excel单元格图片居中

1.单元格内图片

Sub dq()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
shp.Left = (shp.TopLeftCell.Width - shp.Width) / 2 + shp.TopLeftCell.Left
shp.Top = (shp.TopLeftCell.Height - shp.Height) / 2 + shp.TopLeftCell.Top
Next
End Sub

2.合并单元格内图片

Sub dq()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
Set picArea = shp.TopLeftCell.MergeArea
shp.LockAspectRatio = False
shp.Top = shp.Top
shp.Left = shp.Left
shp.Height = picArea.Height - 10
shp.Width = picArea.Width - 10
Next
End Sub

 

posted @ 2022-03-09 09:24  zhouxg72  阅读(736)  评论(0)    收藏  举报