While trying to display an image in a UserForm I get this message:
'438' object doesn't support this property or method image control
In the first textbox (img_path) I input the path to the image's directory.
In the second one I input the file's name (NameImg).
Both textboxes' values are combined into path to the image for image control (ImgControl).
Private Sub Show_Click()
Dim show_img As String
Dim img As String
ing = NameImg.Value + ".jpg"
show_img = img_path.Text + img
ImgControl = LoadPicture(show_img)
End Sub
Private Sub Select_Click()
Dim diaFolder As FileDialog
Dim path As String
Set diaFolder = Application.FileDialog(msoFileDialogFolderPicker)
diaFolder.AllowMultiSelect = False
diaFolder.Title = "Select a Directory"
If diaFolder.Show = -1 Then
path = diaFolder.SelectedItems(1)
path = path + "\"
img_path.Text = path
End If
Set diaFolder = Nothing
End Sub
The path to the jpg file is correct.
As @Tim Williams pointed out I forgot about Picture property here:
ImgControl = LoadPicture(show_img)
it should be
ImgControl.Picture = LoadPicture(show_img)