Excel VBA 自动调整指定列表格图片大小
以下是一个 VBA 代码示例,可用于自动调整 Excel 工作表中指定列中的表格图片大小。该代码将循环遍历指定列中的所有图像,并将其大小调整为指定的宽度和高度。
Sub AutoResizePictures()
Dim pic As Picture
Dim col As Integer
Dim picWidth As Integer
Dim picHeight As Integer
col = 1 '指定列数
picWidth = 100 '指定图片宽度
picHeight = 100 '指定图片高度
For Each pic In ActiveSheet.Pictures
If pic.TopLeftCell.Column = col Then
pic.ShapeRange.LockAspectRatio = msoFalse
pic.Width = picWidth
pic.Height = picHeight
End If
Next pic
End Sub
请注意,此代码假定列中只包含表格图像。如果该列中包含其他类型的图像,则可能会影响代码的功能。
原文地址: https://www.cveoy.top/t/topic/mAJH 著作权归作者所有。请勿转载和采集!