Snip GetAttr Help:-----

Return Values

The value returned by GetAttr is the sum of the following attribute values:

Constant        Value   Description
   
vbNormal        0       Normal
vbReadOnly      1       Read-only
vbHidden        2       Hidden
vbSystem        4       System
vbDirectory     16      Directory or folder
vbArchive       32      File has changed since last backup
Note   These constants are specified by Visual Basic for Applications. The
names can be used anywhere in your code in place of the actual values.

Remarks

To determine which attributes are set, use the And operator to perform a
bitwise comparison of the value returned by the GetAttr function and the
value of the individual file attribute you want. If the result is not zero,
that attribute is set for the named file. For example, the return value of
the following And expression is zero if the Archive attribute is not set:

Result = GetAttr(FName) And vbArchive

A nonzero value is returned if the Archive attribute is set.

-------------

The best way to do this check is 
Result = GetAttr(FName) And vbDirectory
If result = 16 then it's a vb directory

-David


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 09, 2003 9:18 AM
To: [EMAIL PROTECTED]

By the way, the GetAttr(DataDir) function returns a value of 2064.  I'm not
sure what that is yet, though.

Henry Taylor
Applications Analyst
Lutheran Health Network
Ph. (260) 425-3914
----- Forwarded by Henry Taylor/LHI on 07/09/03 09:13 AM -----
 

                    Henry Taylor

                                         To:     [EMAIL PROTECTED]

                    07/09/03 09:09       cc:

                    AM                   Subject:     Accessing files on an
x: drive                               
 

 




     I'm just wondering, in order to try and rule out possibilities in my
troubleshooting, whether I should experience any problems in accessing
files on a mapped drive using BWS and VBA.  I wouldn't think so, but I need
to be sure.
     When I set a data path constant to 'x:\bws\selfpay\data', I get an
invalid directory error.  I have a function that loops through files in a
directory and returns the file names in an array; this allows me to import
multiple files at once.  I've copied the function below.  Based on my
debugging, I believe the error is generated because the GetAttr(DataDir)
does not equal vbDirectory.  What I don't know is why.  I don't know if
there's something inherent in a directory on a mapped drive that will
change the number of the attribute, or if something else is going on.
Anyone have any ideas?

Function GetAllFilesInDir(ByVal DataDir As String) As Variant
    ' Loop through the directory specified in strDirPath and save each
    ' file name in an array, then return that array to the calling
    ' procedure.
    ' Return False if strDirPath is not a valid directory.
    Dim strTempName As String
    Dim varFiles() As Variant
    Dim lngFileCount As Long

    On Error GoTo GetAllFiles_Err

    ' Make sure that strDirPath ends with a "\" character.
    If right$(DataDir, 1) <> "\" Then
        DataDir = DataDir & "\"
    End If

    ' Make sure strDirPath is a directory.
    If GetAttr(DataDir) = vbDirectory Then
        strTempName = Dir(DataDir, vbDirectory)
        Do Until Len(strTempName) = 0
            ' Exclude ".", "..".
            If (strTempName <> ".") And (strTempName <> "..") And
(right(strTempName, 3) <> "rnd") Then
                ' Make sure we do not have a sub-directory name.
                If (GetAttr(DataDir & strTempName) _
                    And vbDirectory) <> vbDirectory Then
                    ' Increase the size of the array
                    ' to accommodate the found filename
                    ' and add the filename to the array.
                    ReDim Preserve varFiles(lngFileCount)
                    varFiles(lngFileCount) = strTempName
                    lngFileCount = lngFileCount + 1
                End If
            End If
            ' Use the Dir function to find the next filename.
            strTempName = Dir()
        Loop
        ' Return the array of found files.
        GetAllFilesInDir = varFiles
    End If
GetAllFiles_End:
    Exit Function
GetAllFiles_Err:
    GetAllFilesInDir = False
    Resume GetAllFiles_End
End Function

Henry Taylor
Applications Analyst
Lutheran Health Network
Ph. (260) 425-3914




The information contained in this message is confidential and is intended for the 
addressee only.  If you have received this message in error or there are any problems, 
please notify the sender immediately.  The unauthorized use, disclosure, copying or 
alteration of this message is strictly forbidden. 



Reply via email to