J'ai utilisé un petit sous-programme pour insert une image dans ma feuille par
ActiveSheet.Pictures.Insert(URL).Select
Cela fonctionne bien avec Excel 2003 (Windows), mais ne fonctionne plus avec Excel 2011 (Mac).
Par conséquent, j'ai modifié mon sous-programme (comme proposé http://www.launchexcel.com/google-maps-excel-demo/ ), mais le sous-programme s'arrête à
theShape.Fill.UserPicture URL
avec le message d'erreur
"-2147024894 (80070002) Fehler der Methode UserPicture des Objets FillFormat"
Le rectangle est vert!
Sub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
Sub Q1 ()Sub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
Dim wks As WorksheetSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
Dim URL As SsortingngSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
Dim i As LongSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
Dim lastRow As LongSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
Dim theShape As ShapeSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
Dim pasteCell As RangeSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
'Feuille de travail utiliséeSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
Définir wks = Feuilles de travail ("Blatt1")Sub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
'Supprimez les forms déjà existantesSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
Pour chacun la forme dans wks.ShapesSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
theShape.DeleteSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
Suivant la formeSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
'Vérifiez toutes les lignes existantes dans la colonne KSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
lastRow = Cells (Rows.Count, "K"). End (xlUp) .RowSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
Pour i = 2 Pour lastRowSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
'les URL sont déjà calculées et stockées dans la colonne KSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
URL = wks.Range ("K" & i) .ValueSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
'essayez de mettre les images dans la colonne LSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
Définissez pasteCell = wks.Range ("L" & i)Sub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
pasteCell.SelectSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
'Créez une forme pour mettre l'image dansSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
'ActiveSheet.Pictures.Insert (URL) .Sélectionner est obsolète et ne fonctionne plus!Sub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
Définissez theShape = wks.Shapes.AddShape (msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200)Sub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
«Remplissez la forme avec l'image après écologisationSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
theShape.Fill.BackColor.RGB = RGB (0, 255, 0)Sub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
l'URL de l'URL de l'image Sheha.Fill.UserPictureSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddShape(msoShapeRectangle, pasteCell.Left, pasteCell.Top, 200, 200) ' fill the shape with the image after greening theShape.Fill.BackColor.RGB = RGB(0, 255, 0) theShape.Fill.UserPicture URL Next i End Sub
Des suggestions ou des conseils? Probablement je suis aveugle comme une chauve-souris …
Avez-vous essayé la syntaxe dans le sens de cela pour définir une forme dans une URL:
Sub Picadder() Dim Pic As Shape Set Pic = ActiveSheet.Shapes.AddPicture("http://stackoverflow.com/content/stackoverflow/img/apple-touch-icon.png", msoFalse, msoTrue, 0, 0, 100, 100) End Sub
Sub Picadder ()Sub Picadder() Dim Pic As Shape Set Pic = ActiveSheet.Shapes.AddPicture("http://stackoverflow.com/content/stackoverflow/img/apple-touch-icon.png", msoFalse, msoTrue, 0, 0, 100, 100) End Sub
Dim Pic As ShapeSub Picadder() Dim Pic As Shape Set Pic = ActiveSheet.Shapes.AddPicture("http://stackoverflow.com/content/stackoverflow/img/apple-touch-icon.png", msoFalse, msoTrue, 0, 0, 100, 100) End Sub
Set Pic = ActiveSheet.Shapes.AddPicture ("http://stackoverflow.com/content/stackoverflow/img/apple-touch-icon.png", msoFalse, msoTrue, 0, 0, 100, 100)Sub Picadder() Dim Pic As Shape Set Pic = ActiveSheet.Shapes.AddPicture("http://stackoverflow.com/content/stackoverflow/img/apple-touch-icon.png", msoFalse, msoTrue, 0, 0, 100, 100) End Sub
Ce code, lorsqu'il est adapté à vos efforts, pourrait ressembler à ce qui suit:
Sub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
Sub Q1 ()Sub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
Dim wks As WorksheetSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
Dim URL As SsortingngSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
Dim i As LongSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
Dim lastRow As LongSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
Dim theShape As ShapeSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
Dim pasteCell As RangeSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
'Feuille de travail utiliséeSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
Définir wks = Feuilles de travail ("Blatt1")Sub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
'Supprimez les forms déjà existantesSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
Pour chacun la forme dans wks.ShapesSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
theShape.DeleteSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
Suivant la formeSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
'Vérifiez toutes les lignes existantes dans la colonne KSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
lastRow = Cells (Rows.Count, "K"). End (xlUp) .RowSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
Pour i = 2 Pour lastRowSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
'les URL sont déjà calculées et stockées dans la colonne KSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
URL = wks.Range ("K" & i) .ValueSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
'essayez de mettre les images dans la colonne LSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
Définissez pasteCell = wks.Range ("L" & i)Sub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
pasteCell.SelectSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
'Créez une forme pour mettre l'image dansSub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
'ActiveSheet.Pictures.Insert (URL) .Sélectionner est obsolète et ne fonctionne plus!Sub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
Définissez theShape = wks.Shapes.AddPicture (URL, pasteCell.Left, pasteCell.Top, 200, 200)Sub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
'Définir la couleur arrière de l'image de forme.Sub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
theShape.Fill.BackColor.RGB = RGB (0, 255, 0)Sub Q1() Dim wks As Worksheet Dim URL As Ssortingng Dim i As Long Dim lastRow As Long Dim theShape As Shape Dim pasteCell As Range ' Used Worksheet Set wks = Worksheets("Blatt1") ' Delete already existing shapes For Each theShape In wks.Shapes theShape.Delete Next theShape ' Check all existing rows in Column K lastRow = Cells(Rows.Count, "K").End(xlUp).Row For i = 2 To lastRow ' the URLs are already computed and stored in column K URL = wks.Range("K" & i).Value ' try to put the images in column L Set pasteCell = wks.Range("L" & i) pasteCell.Select ' Create a Shape for putting the Image into ' ActiveSheet.Pictures.Insert(URL).Select is deprecated and does not work any more!!! Set theShape = wks.Shapes.AddPicture(URL, pasteCell.Left, pasteCell.Top, 200, 200) ' Set shape image backcolor. theShape.Fill.BackColor.RGB = RGB(0, 255, 0) Next i End Sub
Vos urls devront être correctement formatés – j'ai dû utiliser des citations sur mon URL pour l'extrait initial afin de pouvoir fonctionner efficacement, mais cela peut être une solution.
Pour Mac-Excel 2011, il existe une solution de contournement de Michael McLaughlin sur son blog. Évidemment, il n'est pas facile d'attacher des images aux cellules dans Mac-Excel 2011, voire pas du tout. En outre, la search révèle que la question de l'insertion d'images dans un classur excel a été posée plusieurs fois. Il apparaît également qu'il n'a pas été facilement résolu à travers des methods d'image jusqu'à présent dans la search. Ainsi, une solution de travail peut être la meilleure solution.
L'extrait de code, qui a été très adapté et porté sur le blog de Michael, est le suivant:
Function InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
Fonction InsertImageCommentAsWorkAround (titre As Ssortingng, cellAddress As Range)Function InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
'Définir les variables utilisées dans le commentaire.Function InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
Dim ImageCommentContainer Comme commentaireFunction InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
«Effacez les commentaires existants avant d'append de nouveaux.Function InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
Application.ActiveCell.ClearCommentsFunction InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
'Définissez le commentaire en tant que variable locale et atsortingbuez le nom du file à partir du _Function InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
'_ cellAddress comme paramètre d'input pour le commentaire d'une cellule dans sa celluleAddress.Function InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
Définir ImageCommentContainer = Application.ActiveCell.AddCommentFunction InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
'Avec le commentaire, définissez les parameters.Function InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
Avec ImageCommentContainerFunction InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
Texte de text: = ""Function InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
'Avec la forme recouvrant le commentaire, définissez les parameters.Function InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
Avec .ShapeFunction InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
.Fill.UserPicture (cellAddress.Value)Function InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
.ScaleHeight 3 #, msoFalse, msoScaleFormTopLeftFunction InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
.ScaleWidth 2.4, msoFalse, msoScaleFromTopLeftFunction InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
InsertImageCommentAsWorkAround = titreFunction InsertImageCommentAsWorkAround(title As Ssortingng, cellAddress As Range) ' Define variables used in the comment. Dim ImageCommentContainer As comment ' Clear any existing comments before adding new ones. Application.ActiveCell.ClearComments ' Define the comment as a local variable and assign the file name from the _ ' _ cellAddress as an input parameter to the comment of a cell at its cellAddress. ' Add a comment. Set ImageCommentContainer = Application.ActiveCell.AddComment ' With the comment, set parameters. With ImageCommentContainer .Text Text:="" 'With the shape overlaying the comment, set parameters. With .Shape .Fill.UserPicture (cellAddress.Value) .ScaleHeight 3#, msoFalse, msoScaleFormTopLeft .ScaleWidth 2.4, msoFalse, msoScaleFromTopLeft End With End With InsertImageCommentAsWorkAround = title End Function
Je vous conseille d'adapter les jeux de commentaires dans votre boucle et de l'utiliser pour configurer vos images en utilisant le formatting de forme de votre boucle pour définir le formatting des forms de commentaire générées par le code adapté.