Reputation: 59
I have this code. This code opens the file browser. But if you click Cancel or Close appears an error. For this reason I try to put:
If Not IsEmpty(diaFolder.SelectedItems) Then
But this doesn't work. What should I do?
Private Sub Image1_Click()
Dim diaFolder As FileDialog
' Open the file dialog
Set diaFolder = Application.FileDialog(msoFileDialogFolderPicker)
diaFolder.AllowMultiSelect = False
diaFolder.Show
If Not IsEmpty(diaFolder.SelectedItems) Then
Cells(1, 1) = diaFolder.SelectedItems(1)
TextBox1 = diaFolder.SelectedItems(1)
End If
Set diaFolder = Nothing
End Sub
Upvotes: 0
Views: 1304