Description
The Microsoft Excel GETATTR function returns an integer that represents the attributes of a file, folder, or directory.
Syntax
The syntax for the GETATTR function in Microsoft Excel is:
GetAttr ( path )
Parameters or Arguments
- path
- The path to a file, folder, or directory that you wish to retrieve the attributes for.
Note
- The GETATTR function will return one or a combination of the following values:
VB Constant 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
Applies To
- Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000
Type of Function
- VBA function (VBA)
Example (as VBA Function)
The GETATTR function can only be used in VBA code in Microsoft Excel.
Let's look at some Excel GETATTR function examples and explore how to use the GETATTR function in Excel VBA code:
GetAttr("C:\instructions.doc")
Result: 0
GetAttr("H:\Documents\Supplies.xls")
Result: 1
For example:
Dim LResult As Integer
LResult = GetAttr("C:\instructions.doc")
In this example, the variable called LResult would now contain the integer representation of the attributes of the instructions.doc file.
No comments:
Post a Comment