PDA

View Full Version : VBA unable to find file



Grub
06-29-2011, 11:25 PM
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:



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


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

Tommy
06-30-2011, 10:15 AM
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!