|
大佬们好,新手尝试实现在excel的一个sheet里,遍历所有图片,查找有无形状(的左上角)与本图片区域重叠,如有,则组合该图片与所有与其重叠的形状。尝试写了以下代码,但在同时选择图片和形状并将他们组合时,不会写语句了(也就是最里层那几句),网上翻了半天也没找到,特此求助。而且我目前这样只能组合两个,如果一个图片需要与多个形状组合时,我也还没考虑清楚,如有指点,感谢之至。
Sub 组合()
Dim shot As Shape, sign As Shape, jj As Range
Set sh = ActiveWorkbook.ActiveSheet
For Each shot In sh.Shapes
If shot.Type = 13 Then
r1 = shot.TopLeftCell.Row
c1 = shot.TopLeftCell.Column
r2 = shot.BottomRightCell.Row
c2 = shot.BottomRightCell.Column
For Each sign In sh.Shapes
If sign.Type = 1 Then
rs = sign.TopLeftCell.Row
cs = sign.TopLeftCell.Column
Set jj = Intersect(Cells(rs, cs), Range(Cells(r1, c1), Cells(r2, c2)))
If Not jj Is Nothing Then
Range(Array(shot, sign)).Select
Selection.ShapeRange.Group
End If
End If
Next
End If
Next
End Sub |
|