Attributes Property
Sets or returns the attributes of files or folders. Read/write or Read-only, depending on the attribute.
Object. Attributes [= Newattributes]
Arguments
Object
Required. Always the name of a File or Folder object.
Newattributes
Optional. If provided, Newattributes is the new value for the attributes of the specified object.
Settings
The Newattributes argument can have any of the following values or any logical combination of the following values:
Constant Value Description
Normal 0 normal file. No attributes are set.
ReadOnly 1 read-only file. Attribute is read/write.
Hidden 2 Hidden file. Attribute is read/write.
System 4 System file. Attribute is read/write.
Directory Folder or directory. Attribute is read-only.
Archive File has changed since last backup. Attribute is read/write.
Alias 1024 Link or shortcut. Attribute is read-only.
Compressed 2048 compressed file. Attribute is read-only.
Remarks
Attempts to the Read-only attributes (Alias, compressed, or Directory) are ignored.
When setting attributes, it's generally a good idea to the ' The current attributes ', then change the individual attr Ibutes as desired, and finally write the attributes back.
The following code illustrates the use of the Attributes property with a file:
Function Togglearchivebit (filespec)
Dim FSO, F
Set fso = CreateObject ("Scripting.FileSystemObject")
Set f = fso. GetFile (filespec)
If F.attributes and Then
F.attributes = f.attributes-32
Togglearchivebit = "Archive bit is cleared."
Else
F.attributes = f.attributes + 32
Togglearchivebit = "Archive bit is set."
End If
End Function