ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   GetOpenFilename (https://www.excelbanter.com/excel-programming/410948-getopenfilename.html)

steven

GetOpenFilename
 
FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")
If FName < False Then
Set WB = Workbooks.Open(FName)
Else
Exit Sub
End If

I thought if I hit the Cancel key it would take me to Exit Sub in this case
but that is not the case. How do I catch the Cancel key.

Thank you,

Jimmy



Jon Peltier

GetOpenFilename
 
Try

If TypeName(FName) = "Boolean" Then Exit Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Steven" wrote in message
...
FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls),
*.xls")
If FName < False Then
Set WB = Workbooks.Open(FName)
Else
Exit Sub
End If

I thought if I hit the Cancel key it would take me to Exit Sub in this
case
but that is not the case. How do I catch the Cancel key.

Thank you,

Jimmy






All times are GMT +1. The time now is 07:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com