I’m trying to account for a case when the user does not find a file to open:
Dim fn As String
fn = Application.GetOpenFilename("All Files,.", 1, "Select a file", , False)
If fn = False Then
Exit Sub
End If
This does what I want it to when a file is not chosen.
But when the user does choose a file, this If statement creates an error. Can anyone tell me the proper way to accomplish this?
The function does not return the boolean
False, but the string"False", as it will cast the variant from the function into your variable type, so your test should be(changed explanation – thanks @SiddharthRout)