• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to save pictures from userform to excel cell, after click on save button the text is mapping to excel cell but not picture ,please help.

Yubi

New Member
Code:
Option Explicit
Dim fpath As String

Private Sub CommandButton2_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 CommandButton1_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"). Value = 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\Micro for Measurment\\" & 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
 
Last edited by a moderator:
Photos in user forms are saving in file with TextA.Text box names..but not in excel cell..can any one help with code.
 
Back
Top