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 27 28 29 30 31 32 33 34 35 36 37
| Option Explicit
Sub EffacerImages(sWsh As String)
'--- sWsh: nom de la feuille à traiter
Dim sh As Shape
For Each sh In Worksheets(sWsh).Shapes
Debug.Print sh.Name, sh.Type
If sh.Type = 13 Or sh.Type = 11 Then
sh.Delete
End If
Next sh
End Sub
Sub PlacerImage(sFile As String, sWsh As String, sC As String)
'--- sFile: nom du fichier image
'--- sWsh: nom de la feuille destination
'--- sC: adresse cellule destination
Dim chemin As String
If sFile <> "" Then
sFile = ThisWorkbook.Path + "\Photos\" & sFile
If Dir(sFile) = "" Then
MsgBox "Fichier " & sFile & " non trouvé!", vbExclamation, "Anomalie"
Else
With Worksheets(sWsh).Pictures.Insert(sFile)
With .ShapeRange
.LockAspectRatio = msoTrue
.Width = 76
.Height = 76
End With
.Left = Worksheets(sWsh).Range(sC).Left
.Top = Worksheets(sWsh).Range(sC).Top
.Placement = 1
.PrintObject = True
End With
End If
End If
End Sub |
Partager