Excel MkDir Function (VBA)
-function/setattr-function-vba-code.jpg)
How to use the SetAttr Function (VBA)
This Excel tutorial explains how to use the Excel SetAttr function with syntax and examples using VBA.
SUMMARY:
The Excel VBA SetAttr function allows you to set the attributes of a file.
PURPOSE:
To sets the attributes of a file or directory.
RETURN VALUE:
The SetAttr function does not return a value, but rather sets the attributes of a file.
SYNTAX:
SetAttr pathname, attributes
ARGUMENTS:
The SetAttr function syntax has the following arguments:
- pathname: Required. The pathname argument is a string expression that specifies a file name; may include directory or folder, and drive.
- attributes: Required. Constant or numeric expression whose sum specifies file attributes.
- The attributes argument settings are:
Constant Value Description vbNormal 0 (Default) Specifies Normal files. vbReadOnly 1 Specifies read-only files. vbHidden 2 Specifies hidden files. vbSystem 4 Specifies system files. Not available on the Macintosh. vbArchive 32 File has changed since last backup. Not available on the Macintosh. vbAlias 64 Specified file name is an alias. Available only on the Macintosh.
REMARKS:
- If you try to set the attributes of an open file, a run-time error occurs.