|
本帖最后由 hwc2ycy 于 2012-10-21 15:08 编辑
在03里测式自适应高度又发现一个问题。图片删除后,行高没变,原有的小图一旦插入进来,反倒尺寸比例又不对了。重新改了下,在删除图片对象后,自动把行高复位。- Private Sub CommandButton1_Click()
- Dim oShp As Shape
- Dim rng As Range, sPic As String
- Application.ScreenUpdating = False
- For Each oShp In Shapes
- With oShp
- If .Name Like "*Picture*" Or .Name Like "*图片*" Then .Delete
- End With
- Next
- Range("a2:a" & [a65536].End(xlUp).Row).RowHeight = Range("a1").RowHeight
- 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
- Selection.Width = .Offset(0, 3).Width - 2
- .RowHeight = Selection.Height + 2
- End With
- End If
- Next
- Application.ScreenUpdating = True
- [d1].Select
- End Sub
复制代码 |
|