How to copy pictures from userform and paste in excel cell, after click on save button the text is mapping to excel cell but not picture, any modification in below Code.
Code
Option ExplicitDim fpath As String
Private Sub TakePhoto_Click()
Dim RetVal, base, i, picName, picPath, picNumber
picName = "Image" & picNumber & ".bmp"
ChDir (ActiveWorkbook.Path)
base = ActiveWorkbook.Path & "\"
picPath = base & picName
RetVal = Shell(base & "CommandCam.exe /filename """ & picPath & """", vbHide)
For i = 0 To 2 Application.Wait (Now + TimeValue("00:00:01")) Next
fpath = picPath
Image1.Picture = LoadPicture(fpath)
End Sub
Private Sub Save_Click()
Dim x As Long
Dim Y As Worksheet
Set Y = Sheets("Data1")
x = Y.Range("A" & Rows.Count).End(xlUp).Row
With Y
.Cells(x + 1, "A").Value = TextA.Text
.Cells(x+1,"B"). Paste= Image1.Picture
.Cells(x + 1, "C").Value = TextC.Text
.Cells(x + 1, "D").Value = TextD.Text
.Cells(x + 1, "E").Value = TextE.Text
.Cells(x + 1, "F").Value = TextF.Text
.Cells(x + 1, "G").Value = TextG.Text
End With
Dim i As String
i = TextPart.Text
FileCopy fpath, "C:\\Users\HP\Desktop\Userform\\" & i & ".JPG"
Me.TextPart.Text = ""
'clear the data
TextA.Text = ""
TextC.Text = ""
TextD.Text = ""
TextE.Text = ""
TextF.Text = ""
TextG.Text = ""
fpath = ""
Image1.Picture = LoadPicture("")
End Sub
Display More