1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Option Explicit
Sub test()
Dim tabloimage(), WindoWname As String, WbKSource As Workbook, delta As Long, shap, i As Long
delta = 8
WindoWname = ThisWorkbook.Name
Set WbKSource = Workbooks.Open(ThisWorkbook.Path & "\ES-Catalogue.xlsm")
'on rassemble les images dans un tableau
With WbKSource.Sheets("Param Services")
For Each shap In .Shapes
If shap.TopLeftCell.Row >= 1 And shap.TopLeftCell.Row <= 50 And shap.TopLeftCell.Column = 4 Then
i = i + 1: ReDim Preserve tabloimage(1 To i): shap.Name = "B" & delta: tabloimage(i) = shap.Name: delta = delta + 5
End If
Next
With .Shapes.Range(tabloimage): .Group.Copy: .Ungroup: End With
End With
Windows(WindoWname).Activate
With ActiveSheet
Cells(8, 2).Select: .Paste: .Shapes(1).Ungroup
For Each shap In .Shapes
If shap.Name <> "Button 1" Then shap.Left = .[B1].Left: shap.Top = .Range(shap.Name).Top
Next
End With
'on ferme la source image on en a plus besoins
Application.DisplayAlerts = False
WbKSource.Close
End Sub |