|
- Private Sub CommandButton1_Click()
- Dim oShp As Shape
- Dim rng As Range, sPic As String
- For Each oShp In Shapes
- With oShp
- If .Name Like "*Picture*" Or .Name Like "*图片*" Then .Delete
- End With
- Next
- Application.ScreenUpdating = False
- For Each rng In Range("a2:a" & [a65536].End(xlUp).Row)
- sPic = ThisWorkbook.Path & "" & rng & ".jpg"
- If Dir(sPic) <> "" Then
- Pictures.Insert(sPic).Select
- 'Selection.ShapeRange.LockAspectRatio = msoFalse
- With rng
- Selection.Left = .Offset(0, 3).Left + 2
- Selection.Top = .Offset(0, 3).Top + 2
- 'Selection.Height = .Offset(0, 3).Height - 2
- Selection.Width = .Offset(0, 3).Width - 2
- .RowHeight = Selection.Height + 4
- End With
- End If
- Next
- Application.ScreenUpdating = True
- [d1].Select
- End Sub
复制代码 10里图片由于默认是锁定纵横比的,所以一旦设置了宽度,图片的高度就会根据比例自动缩小。
再来设置图片的高度就无意义。
通过修改单元格的行高来适应图片的高度。这样图片的比例一致,相对于原图来说不会有失真。 |
|