PDA

View Full Version : Solved: File IO low level functions -- not working



jcdv
05-23-2009, 07:40 AM
This is very weird.
By some reason, a macro excel I have working before properly suddenly stop to function.

It uses various file IO low level functions, such as this:

===

Public Function FileFolderExists(strFullPath As String) As Boolean
On Error GoTo EarlyExit
If Not Dir(strFullPath, vbDirectory) = vbNullString Then FileFolderExists = True

EarlyExit:
On Error GoTo 0
End Function
===

The problem is that it issues no error at all, but it doesn't work fine. It always return true, whether the folder exists or not. All other file IO functions have the same problem: No error, but they do nothing.

The curious thing is that it used to work well, but now they don't.

Question: Is there a configuration setting that needs to be done for this to work? Please help, I'm really confused. :think:

jcdv
05-23-2009, 08:03 AM
I found what the problem was: The file IO operation where done in the current directory (when you hit File|open), not in the folder where the workbook was located, which is what I wanted.

To solve this, I added the following:

'Work in the folder where the worksheet is
ChDir ThisWorkbook.Path

That closes the issue :-).
Maybe this helps someone.