根据单元格的宽高设置图片的宽高,参考
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("d:\test.xls")
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim Rng As MSExcel.Range
Dim Pic As MSExcel.shape
For Each Pic In ws.shapes
On Error Resume Next
rng = pic.TopLeftCell
With Pic
If .Height / .Width > rng.Height / rng.Width Then
.Height = rng.Height - 5
.Top = rng.Top + 2.5
.Left = rng.Left + (rng.Width - .Width) / 2
.Placement = 1
Else
.Width = rng.Width - 5
.Left = rng.Left + 2.5
.Top = rng.Top + (rng.Height - .Height) / 2
.Placement = 1
End If
End With
Next
App.Visible = True
[此贴子已经被作者于2018/4/20 17:05:38编辑过]