Bonjour à tous,
Je cherche à insérer 2 images dans une feuille Excel via VBA; en effet, le but c'est si l'utilisateur choisit par exemple le mot "ab", l'image associée à "ab" s'affiche, et s'il choisit par exemple "cd" l'image associée à "cd" s'affiche. J'ai écrit un code VBA qui marche, mais dés que je supprime les images de mon ordinateur les images ne s'affichent plus!
Voici mon code VBA:
Dim img As Object
For Each img In ActiveSheet.Shapes
If Not Intersect(img.TopLeftCell, Range("$A$51:$D$58")) Is Nothing Then
img.Delete
End If
Next img
If ThisWorkbook.Sheets("Feuille1").Cells(9, 17) = "ab" Then
ThisWorkbook.Sheets("Feuille 2").Cells(51, 2).Select
ActiveSheet.Pictures.Insert("C:\Users\s044408\Desktop\logo\Logo1.jpg").Select
ActiveWindow.ScrollRow = 2
Selection.ShapeRange.ScaleWidth 0.5, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.5, msoFalse, msoScaleFromTopLeft
End If
If ThisWorkbook.Sheets("Feuille 1").Cells(9, 17) = "cd" Then
ThisWorkbook.Sheets("Feuille2").Cells(51, 2).Select
ActiveSheet.Pictures.Insert("C:\Users\s044408\Desktop\logo\Logo2.jpg").Select
ActiveWindow.ScrollRow = 2
Selection.ShapeRange.ScaleWidth 0.5, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.5, msoFalse, msoScaleFromTopLeft
End If
Je cherche à insérer 2 images dans une feuille Excel via VBA; en effet, le but c'est si l'utilisateur choisit par exemple le mot "ab", l'image associée à "ab" s'affiche, et s'il choisit par exemple "cd" l'image associée à "cd" s'affiche. J'ai écrit un code VBA qui marche, mais dés que je supprime les images de mon ordinateur les images ne s'affichent plus!
Voici mon code VBA:
Dim img As Object
For Each img In ActiveSheet.Shapes
If Not Intersect(img.TopLeftCell, Range("$A$51:$D$58")) Is Nothing Then
img.Delete
End If
Next img
If ThisWorkbook.Sheets("Feuille1").Cells(9, 17) = "ab" Then
ThisWorkbook.Sheets("Feuille 2").Cells(51, 2).Select
ActiveSheet.Pictures.Insert("C:\Users\s044408\Desktop\logo\Logo1.jpg").Select
ActiveWindow.ScrollRow = 2
Selection.ShapeRange.ScaleWidth 0.5, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.5, msoFalse, msoScaleFromTopLeft
End If
If ThisWorkbook.Sheets("Feuille 1").Cells(9, 17) = "cd" Then
ThisWorkbook.Sheets("Feuille2").Cells(51, 2).Select
ActiveSheet.Pictures.Insert("C:\Users\s044408\Desktop\logo\Logo2.jpg").Select
ActiveWindow.ScrollRow = 2
Selection.ShapeRange.ScaleWidth 0.5, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.5, msoFalse, msoScaleFromTopLeft
End If