Text Documents (Writer)
HTML Documents (Writer Web)
Spreadsheets (Calc)
Presentations (Impress)
Drawings (Draw)
Database Functionality (Base)
Formulae (Math)
Charts and Diagrams
Macros and Scripting
Office Installation
Common Help Topics
OneOffice Logo

SetAttr Statement

Sets the attribute information for a specified file.

Syntax:


SetAttr FileName As String, Attribute As Integer

Parameters:

FileName: Name of the file, including the path, that you want to test attributes of. If you do not enter a path, SetAttr searches for the file in the current directory. You can also use URL notation.

Attribute: Bit pattern defining the attributes that you want to set or to clear:

Value

Named constant Value Definition
ATTR-NORMAL 0 Normal files.
ATTR-READONLY 1 Read-only files.
ATTR-HIDDEN 2 Hidden file

You can set multiple attributes by combining the respective values with a logic OR statement.

Error codes:

5 Invalid procedure call

53 File not found

70 Access denied

Example:


Sub ExampleSetGetAttr
 On Error Goto ErrorHandler ' Define target for error handler
 If Dir("C:\test",16)="" Then MkDir "C:\test"
 If Dir("C:\test\autoexec.sav")="" Then FileCopy "c:\autoexec.bat", "c:\test\autoexec.sav"
 SetAttr "c:\test\autoexec.sav" ,0
 FileCopy "c:\autoexec.bat", "c:\test\autoexec.sav"
 SetAttr "c:\test\autoexec.sav" , ATTR-READONLY
 Print GetAttr( "c:\test\autoexec.sav" )
 End
ErrorHandler:
 Print Error
 End
End Sub