ExcelBanter

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

Antnonio Castro

GetOpenFilename() errors
 
When I use "s = application.GetOpenFilename()" I have two options: a) s =
False (boolean) because I canceled the function; b) s = the selected file (no
boolean).

When I use Y = ubound(s), Excel displays a 13 error, if s = False.

When I use a "if s = False then.." statement, Excel displays a 13 error if s
= the selected file.

I had tried the "on error resume next" instruction but it does not
function.. How can I deal with this situation?


rylo[_3_]

GetOpenFilename() errors
 

Hi

Try something like


Code:
--------------------
Sub ddd()
Dim GetFileName
GetFileName = Application.GetOpenFilename()
If GetFileName < False Then
MsgBox "got a file name " & GetFileName
Else
MsgBox "Cancelled out"
End If

End Sub
--------------------


rylo


--
rylo
------------------------------------------------------------------------
rylo's Profile: http://www.thecodecage.com/forumz/member.php?userid=28
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=28929


Antnonio Castro

GetOpenFilename() errors
 


"rylo" wrote:


Hi

Try something like


Code:
--------------------
Sub ddd()
Dim GetFileName
GetFileName = Application.GetOpenFilename()
If GetFileName < False Then
MsgBox "got a file name " & GetFileName
Else
MsgBox "Cancelled out"
End If

End Sub
--------------------


rylo


--
rylo
------------------------------------------------------------------------
rylo's Profile: http://www.thecodecage.com/forumz/member.php?userid=28
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=28929

Thank you Rylo, the key was the "Dim GetFileName"

Antonio


All times are GMT +1. The time now is 05:50 PM.

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