我有一个带有一堆文本框的用户表单。最终用户将测试数据输入表格,点击“提交”按钮后,此信息将保存到 Excel 表中。我想知道如何使用户可以将计算机中的图像输入到表单中。
要求:最终用户能够从他们的计算机中选择图像,然后单击表单上的提交以将其插入到 Excel 工作表中。
Private Sub CommandButton3_Click()
Dim image As FileDialog
Set image = Application.FileDialog(msoFileDialogFilePicker)
Dim vrtSelectedPicture As Variant
With image
If .Show = -1 Then
For Each vrtSelectedPicture In .SelectedItems
'Show path in textbox
TextBox71.Text = .SelectedItems(1)
Next vrtSelectedPicture
'The user pressed Cancel.
Else
End If
End With
'Set the object variable to Nothing
Set image = Nothing
End Sub