Sub Affiche_Image() Dim Ws As Worksheet ' Used to manipulate the leaf object more easily Dim Image As String ' Will contain the name of the image Dim Lg As Long ' Number of the last row column B
. LockAspectRatio = msoFalse ' You can resize it as you want . Left = Ws.Cells(Lg, "B"). Left ' Left Position . Top = Ws.Cells(Lg, "B"). Top ' Position High . width = ws.cells(lg, "b"). Width ' Width . height = ws.cells(lg, "b"). Height ' height End With If Err.Number > 0 Then ' If an error (image not present) MsgBox . Cells(Lg, "A") & vbCr & "Non-existent image" ' It is reported End If Next Lg End With End Sub
Sub Efface_Images() Dim Ws As Worksheet ' Used to manipulate the leaf object more easily Dim Sh As Shape ' Used to manipulate shapes (images) already displayed
Set Ws = Sheets("Purchase Order") ' Sheet Name
With Ws
For each sh in . Shapes ' Browse the entire shapes collection (images) If Not Intersect(. Columns(1), Sh.TopLeftCell) Is Nothing Then ' if it is in column 1 Sh.Delete ' We delete it End If Next Sh End With
So in summary, I have an "A" column where I put the article number (starting with line 2)
And in column "B" The image corresponding to the article number is displayed when I click on the button (there are 2 buttons with the macro, one to display the images one to delete)