Вы можете выполнить sh это по-разному, используя Shape Range Collection Object
, и либо использовать Shepes.SelectAll
, либо выбрать каждый тип объекта формы без использования аргумента Replace
, либо выбрать конкретный c Range
. При необходимости измените тип формы и диапазон. Если у вас есть вопросы, задавайте их.
Пример 1: Использовать объект коллекции Shape Range
Dim shprng As ShapeRange
ActiveSheet.Shapes.SelectAll
Set shprng = Selection.ShapeRange
shprng.Align 3, 0 '3 is the enumeration for msoPicture, and 0 is the enumeration for msoFalse
Пример 2: Выберите тип формы
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If shp.Type = 13 Then shp.Select False '13 is the enumeration for msoPicture
Next shp
With Selection.ShapeRange
.Align 3, 0 '3 is the enumeration for msoALignTops, and 0 is the enumeration for msoFalse
End With
Пример 3: Использовать спецификацию c Диапазон
Dim shp As Shape, rng As Range
Set rng = ActiveSheet.Range("D4:O20")
For Each shp In ActiveSheet.Shapes
If Not Intersect(Range(shp.TopLeftCell, shp.BottomRightCell), rng) Is Nothing And shp.Type = 13 Then shp.Select False '13 is the enumeration for msoPicture
Next shp
With Selection.ShapeRange
.Align 3, 0 '3 is the enumeration for msoALignTops, and 0 is the enumeration for msoFalse
End With