Private Sub CommandButton1_Click()
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.ButtonName = "Submit"
.Title = "Select an image file"
.Filters.Add "Image", "*.gif; *.jpg; *.jpeg", 1
If .Show = -1 Then
' file has been selected
' e.g. show path in textbox
' Me.Label9.Text = .SelectedItems(1)
' e.g. display preview image in an image control
Me.Image1.PictureSizeMode = fmPictureSizeModeZoom
Me.Image1.Picture = LoadPicture(.SelectedItems(1))
Else
' user aborted the dialog
End If
End With
End Sub
Private Sub CommandButton2_Click()
Dim emptyRow As Long
'Make Job Sheets Active
Worksheets("PartDB").Activate
'Determine Empty Row
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
'Enter Data from Form into Table
Worksheets("PartDB").Cells(emptyRow, 1).Value = PartNumber.Value
Worksheets("PartDB").Cells(emptyRow, 2).Value = Description.Value
Worksheets("PartDB").Cells(emptyRow, 3).Value = MatBox1.Value
Worksheets("PartDB").Cells(emptyRow, 4).Value = ThickBox.Value
Worksheets("PartDB").Cells(emptyRow, 5).Value = FinishBox.Value
Worksheets("PartDB").Cells(emptyRow, 6).Value = ProcessBox1.Value
Worksheets("PartDB").Cells(emptyRow, 7).Value = KitNumber.Value
'Worksheets("PartDB").Cells(emptyRow, 8).Shapes.AddPicture =
Unload Me
End Sub
Good morning,
For the life of me, I have been struggling to get the selected Picture from the userform to insert into the Table alongside the other values.
Every other aspect works flawlessly but I’ve tried several ways to get the selected image to insert, I either get the code value of the image or an error message.
So I select the image via the UserForm, all details are filled out and when the Command Button is clicked I want to insert all that information into a table with the Image.
I can get all text based info to insert except the image. As you can see I have commented out the last insertion as it’s been frustrating me for a while.
Matt_B is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.