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

GetAttr Function

Returns a bit pattern that identifies the file type or the name of a volume or a directory.

Syntax:


GetAttr (Text As String)

Return value:

Integer

Parameters:

Text: Any string expression that contains an unambiguous file specification. You can also use URL notation.

This function determines the attributes for a specified file and returns the bit pattern that can help you to identify the following file attributes:

Error codes:

5 Invalid procedure call

53 File not found

Value

Named constant Value Definition
ATTR-NORMAL 0 Normal files.
ATTR-READONLY 1 Read-only files.
ATTR-HIDDEN 2 Hidden file
ATTR-SYSTEM 4 System file
ATTR-VOLUME 8 Returns the name of the volume
ATTR-DIRECTORY 16 Returns the name of the directory only.
ATTR-ARCHIVE 32 File was changed since last backup (Archive bit).

If you want to know if a bit of the attribute byte is set, use the following query method:

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" ,1
 Print GetAttr( "c:\test\autoexec.sav" )
 End
ErrorHandler:
 Print Error
 End
End Sub