Fileexists function
Hi,
I can't get this piece of code to work using the sub(filexists) funtion taken from the Excel VBA 2002 book. No matter whether the file exists or not the code always executes the else statement rather than the next statement. Every other part of the code works fine.
Any help greatly appreciated as it's been driving me mad for ages. I'm sure it's something simple.
Thanks
Dave
checkiffileisopen:
stfullname = pathname & "\" & stFileName & ".xls"
stFileName = GetFileName(stfullname)
If IsWorkbookOpen(stFileName) Then
Set Wkb = Workbooks(stFileName)
Wkb.Activate
Else
ChDir pathname
If FileExists(stFileName) = True Then
Set Wkb = Workbooks.Open(Filename:=stfullname)
Else
GoTo dontprocess:
End If
End If
|