Hello,
I have the following code to open a file dialog so a person can select a file:
The problem i'm having is if i open the file dialog box and select Cancel, it pops the file dialog up again, then this time when i hit Cancel it shows me my MsgBox "No file selected". I know it has something to do with the For/Next statement, but i can't get it to just Cancel and show MsgBoxCode:Dim f As Object Set f = Application.FileDialog(3) f.AllowMultiSelect = False If f.Show = -1 Then For i = 1 To f.SelecteItems.Count sFile = Filename(f.SelectedItems(i), sPath) Me.txtSelectedFile = sPath & s File Next Else If f.Show = 0 Then MsgBox "No file selected" End If End If
I appreciate any help!