Heenan, Lambert
Lambert.Heenan at AIG.com
Tue Jun 29 08:54:59 CDT 2004
Or if you want a more robust way to do it (some crazy user just might have made a DIRECTORY with the name of the FILE you are looking for)... Function FileExists(strFile As String) As Boolean ' Comments : Determines if the file exists ' Works for hidden files and folders ' Parameters: strFile - file to check ' Returns : True if the file exists, otherwise false Dim intAttr As Integer Dim errnum As Long On Error Resume Next 'GET THE FILE ATTRIBUTE INSTEAD OF THE LENGTH OF THE FILE NAME intAttr = GetAttr(strFile) FileExists = (Err.Number = 0) On Error GoTo 0 End Function and then there is the complementary function... Function isDirectory(sDir As String) As Boolean On Error Resume Next isDirectory = (GetAttr(sDir) And vbDirectory) <> 0 If Err.Number <> 0 Then isDirectory = False On Error GoTo 0 End Function HTH Lambert > -----Original Message----- > From: paul.hartland at fsmail.net [SMTP:paul.hartland at fsmail.net] > Sent: Tuesday, June 29, 2004 4:20 AM > To: Access Developers discussion and problem solving > Subject: Re: Re: [AccessD] Check If File Exists In Directory - Cant > Think > > Thanks.....I know it's Tuesday but it's as if it's a monday morning > moment... > > > > > > Message date : Jun 29 2004, 09:15 AM > >From : "Gustav Brock" > To : "Access Developers discussion and problem solving" > Copy to : > Subject : Re: [AccessD] Check If File Exists In Directory - Cant Think > Hi paul > > That would be > > If Len(Dir("C:\Branston\OWP_Template.xls", vbNormal)) > 0 then > ... > End If > > /gustav > > > > To all, > > > I hate to ask this but I can't for the life of me think of the command > to use to check if a file exists within a certain directory. Basically I > just need to check if OWP_Template.xls exists in the > > directory C:\Branston\ > > > Thanks for all your help..... > > > Paul Hartland > > > P.S. Feel free to come out with silly comments like you should change > career to something like a bin man etc.....ha ha > > -- > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- > > Whatever you Wanadoo: > http://www.wanadoo.co.uk/time/ > > This email has been checked for most known viruses - find out more at: > http://www.wanadoo.co.uk/help/id/7098.htm > -- > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com