Good morning.
Greetings to all, I'm doing a small macro in excel with vb-userform where I have several text fields, this data is passed to an excel sheet with a button.
This image I want to add it to my sheet. I am using this code, the text fields if you copy it but the image does not.
Private Sub cmdAgregar_Click()
Sheets("Formulario").Select
NR = Application.WorksheetFunction.CountA(Range("A:A"))
Cells(NR + 1, 1) = txtModelo
Cells(NR + 1, 2) = txtTallaBase
Cells(NR + 1, 3) = txtCliente
Cells(NR + 1, 4) = txtFechaElaboracion
Cells(NR + 1, 5) = txtDescripcion
Cells(NR + 1, 6) = txtTemporada
Cells(NR + 1, 7) = txtEntrega
Cells(NR + 1, 121) = LoadPicture(Image1)
End Sub
The 121 is where I want to show the image and with LoadPicture (Image1), I get error 13, the types do not match.
By means of my button (Upload) it allows me to add the image in the Image tool.
Private Sub cmdCargar_Click()
Public foto As Variant
foto = Application.GetOpenFilename(FileFilter:= _
"Imagen (*.gif;*.jpg;*.jpeg;*.bmp), *.gif;*.jpg;*.jpeg;*.bmp", _
Title:="Seleccionar imagen", MultiSelect:=False)
If foto = False Then
Exit Sub
End If
If Not IsEmpty(Image1.Picture) Then
Image1.Picture = Nothing
End If
Image1.Picture = LoadPicture(foto)
Image1.PictureSizeMode = fmPictureSizeModeStretch
Image1.Width = 100
Image1.Height = 100
End Sub
Now in this loaded image I want to copy or send it to an excel cell Cells(NR + 1, 121)
, which method could use some suggestion.
I appreciate your support.