GetAttr

Returns an integer that represents the attributes of a file or folder.

Syntax
      GetAttr (path)

Key
   path  The path to the file/folder.

The GetAttr() function can be used in VBA or in an SQL query (VBConstants can only be referenced in VBA code).

GetAttr will return one or a combination of the following values:

VBConstant Value Explanation
vbNormal 0 Normal
vbReadOnly 1 Read-only
vbHidden 2 Hidden
vbSystem 4 System file
vbDirectory 16 Directory or folder
vbArchive 32 File has been changed since last backup
vbAlias 64 File name is an alias

To test if a folder (or server) exists at all, you can use this function from Allen Browne

Function FolderExists(strPath As String) As Boolean
   On Error Resume Next     
   FolderExists = ((GetAttr(strPath) And vbDirectory) = vbDirectory) 
End Function

Example

Dim intDemo as integer

intDemo = GetAttr ("C:\docs\demo.doc")

“If you are planning for a year, sow rice; if you are planning for a decade, plant trees; if you are planning for a lifetime, educate people” ~ Chinese Proverb

Related:

Int - Return the integer portion of a number.


© Copyright SS64.com 1999-2016
Some rights reserved