Consulting

Results 1 to 2 of 2

Thread: VBA unable to find file

  1. #1
    VBAX Newbie
    Joined
    Jun 2011
    Posts
    1
    Location

    VBA unable to find file

    Hi, I am using CitectVBA to open known files. I am calling the VBA function from cicode with two file paths as arguements.

    These are the paths:
    TempPath = "C:\Reports\Temp\DailyRep.dbf"
    RepPath = "C:\Reports\DailyRep.dbf"


    Below is my code to check if the files exist:


    [VBA]
    Function ParseData(TempPath As String, RepPath As String) As String


    If Dir(TempPath) = ""Then
    MsgBox TempPath & " Not Found. "
    Exit Function
    End If
    If Dir(RepPath) = ""Then
    MsgBox RepPath & " Not Found. "
    Exit Function
    End If

    End Function
    [/VBA]

    I have not used VBA before so this may be a simple problem. For some reason the Dir function cannot find the files and is opening the message box and the correct path is being displayed. Can you please tell me a reason why this could be happening. There are no spaces in my path, do I need to handle the "\" is a special way so it can read the path? Thanks

    Added VBA code tags: Tommy

  2. #2
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    FWIW I ran this in excel with a know directory and file specified and it worked. I do not know anything about CitectVBA.

    Welcome to the board!

Posting Permissions

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