G
Guest
Hi
I let user to open his/her own file with this VBA......
Sub ConsolFile()
Application.Workbooks.Open (GetFileName)
End Sub
Function GetFileName()
'Get a FileName (may change current drive/directory.)
Filename = Application.GetOpenFilename
'Get the current directory and drive
TempDir = CurDir()
'Switch back to original drive
ChDrive Mid(TempDir, 1, 1)
'Switch back to the orginal directory
ChDir TempDir
'Return the filename
GetFileName = Filename
End Function
It doesn't work 'cause it return false when user cancel....How can I fix
this problem?
Thanks
Jafery
I let user to open his/her own file with this VBA......
Sub ConsolFile()
Application.Workbooks.Open (GetFileName)
End Sub
Function GetFileName()
'Get a FileName (may change current drive/directory.)
Filename = Application.GetOpenFilename
'Get the current directory and drive
TempDir = CurDir()
'Switch back to original drive
ChDrive Mid(TempDir, 1, 1)
'Switch back to the orginal directory
ChDir TempDir
'Return the filename
GetFileName = Filename
End Function
It doesn't work 'cause it return false when user cancel....How can I fix
this problem?
Thanks
Jafery