Insert an image in the Excel spreadsheet with VBA but without the link to the original image

Asked

Viewed 282 times

2

I am creating a table generator in Excel and need to insert several images that are in a certain folder.

I make this insertion by the following code:

altura = 3
On Error Resume Next
For L = 1 To ultimalinha 
    If Guia.Cells(L, 1).Value <> "" Then
  'DEFINE O NOME DA IMAGEM
        arquivo_img = Replace(Guia.Cells(L, 2).Value, "/", "")
'INSERE A IMAGEM E DEFINE O NOME
        Guia.Pictures.Insert(caminho_img & arquivo_img & ".jpg").Name = arquivo_img
'POSICIONA CORRETAMENTE A IMAGEM E REDIMENSIONA
        With Guia.Pictures(arquivo_img)
            .ShapeRange.Height = 89
            .Top = altura
            .Left = (Guia.Columns("A:A").Width) / 2 - .ShapeRange.Width / 2
        End With
    End If
'Guia.Shapes.Range(Array(arquivo_img)).ShapeRange.Item(1).Hyperlink.Delete
altura = Guia.Cells(L, 1).Height + altura

Next L

I tried to use the method Guia.Shapes.Range(Array(arquivo_img)).ShapeRange.Item(1).Hyperlink.Delete to break the link of the image but without success.

The code that inserts the image in the spreadsheet I already have, however, I need some procedure or command that makes this image not have any external link, that if I move the folder or even send the spreadsheet by email, the images continue in the spreadsheet.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.