GetAttr Function

Named Arguments

No

Syntax

GetAttr(pathname)


pathname

Use: Required

Data Type: String

File and optional path name.

Return Value

An integer representing the attributes set for the file or folder, being the sum of the following constant 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

Description

Determines which attributes have been set for a file, directory, or folder.

Rules at a Glance

  • pathname may optionally include a directory or folder name and a drive letter, including a network drive. pathname can also follow the UNC format of //machine_name/drive.

  • You can check if a particular attribute has been set by performing a bit-wise comparison of the GetAttr return value and the value of the attribute constant using the And operator. A nonzero result means that the particular attribute has been set; conversely, a zero value indicates that the attribute has not been set. For example:

    If GetAttr(myfile.txt) And vbReadOnly = 0 then
        Msgbox "The file is Read-Write"
    Else
        MsgBox "The file is Read-Only"
    End If

Programming Tips and Gotchas

The file attribute constants are defined to be globally available for use within your projects.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.108.102