View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] vrzimmerm@hotmail.com is offline
external usenet poster
 
Posts: 28
Default Detecting user cancel out of "File Open" input box

The following macro segment is supposed to detect if the user
cancelled out of an "Open File" input window, but I keep getting a
"subscript out of range" error. What am I doing wrong?

Dim FName As Variant
FName = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
If Not FName = False Then Workbooks.Open FName
Application.DisplayAlerts = False

If FName < False Then
Set wb = Workbooks.Open(FName)
MsgBox "File open cancelled"
wb.Close
End If

Thanks.