Effacer photo avant d'introduire une nouvelle

pierchan

XLDnaute Nouveau
Merci de m'accueillir sur le forum.
Je sollicite votre aide, car si j'ai réussi à introduire des photos dans mon tableau, et à les faire apparaitre au bon endroit, je ne parviens pas à effacer la photo n-1 avant d'introduire la photo n.
Merci pour ce que vous allez faire pour moi.

Sub Test()

Dim Val1
Val1 = Sheets("Autorisations de conduite").[E2].Value
Dim val2 As String
val2 = ThisWorkbook.Path & "\Photos\"
Dim val3 As String
val3 = val2 & Val1 & ".jpg"
Range("E2").Select
On Error GoTo erreur

ActiveSheet.Pictures.Insert(val3).Select

Selection.ShapeRange.IncrementLeft 235
Selection.ShapeRange.IncrementTop 100
Selection.ShapeRange.Height = 172.25
Selection.ShapeRange.Width = 173.75
Selection.ShapeRange.ScaleWidth 0.68, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.67, msoFalse, msoScaleFromTopLeft

ActiveSheet.Pictures.Insert(val3).Select

Selection.ShapeRange.IncrementLeft 235
Selection.ShapeRange.IncrementTop 690
Selection.ShapeRange.Height = 172.25
Selection.ShapeRange.Width = 173.75
Selection.ShapeRange.ScaleWidth 0.68, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.67, msoFalse, msoScaleFromTopLeft
GoTo Fin
erreur:
MsgBox "Vérifier si la photo est dans le répertoire"
Fin:
Exit Sub

End Sub
 

JpM79

XLDnaute Junior
Re : Effacer photo avant d'introduire une nouvelle

Salut,
je ne suis pas un pro sur excel mais pour ton problème, regarde la propriété Picture, il me semble que grace a cette propriété on peut charger ou decharger une image.

exemple:

Dim Photo As String
Image1.Picture= LoadPicture() ' Décharge l'Image
Photo = "C:\chemin de la photo\photo.jpg"
Image1.Picture = LoadPicture(Photo) ' charge l'image

Ps: le contrôle image supporte les formats d'image bmp, cur, gif, ico, jpg et wmf

A voir si tu peux adapter pour ton problème

@+
 

Discussions similaires

Membres actuellement en ligne

Statistiques des forums

Discussions
311 725
Messages
2 081 941
Membres
101 848
dernier inscrit
Djigbenou