Consulting

Results 1 to 2 of 2

Thread: Solved: File IO low level functions -- not working

  1. #1
    VBAX Newbie
    Joined
    May 2009
    Posts
    2
    Location

    Question Solved: File IO low level functions -- not working

    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:

    ===
    [VBA]
    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
    [/VBA]===

    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.

  2. #2
    VBAX Newbie
    Joined
    May 2009
    Posts
    2
    Location
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •