Verifying if a file exists?
How do you verify if a spreadsheet file exists using VBA code within an Access environment. What I am trying to do is verify that a .xls file exists...if it doesn't then I need to create this file.
I have no idea how to code VBA. I'm just a VB programmer and need some serious help with this.
Thanks in advance,
Blake
Re: Verifying if a file exists?
I'm not sure if Access supports Dir, but in VB you could use the following:
VB Code:
If Dir("C:\folder\file.xls") = "" Then
'File doenst exist
Else
'File does exist
End If
edit: corrected, thanks sciguyryan :thumb:
Re: Verifying if a file exists?
Quote:
Originally Posted by si_the_geek
I'm not sure if Access supports Dir, but in VB you could use the following:
VB Code:
If Dir("C:\folder\file.xls) = "" Then
'File doenst exist
Else
'File does exist
End If
You missed a " in there, it should be:
VB Code:
If Dir("C:\folder\file.xls") = "" Then
'File doenst exist
Else
'File does exist
End If
Cheers,
RyanJ