Friday, October 15, 2021

Getattr function

Note: The function, method, object, or property described in this topic is disabled if the Microsoft Jet Expression Service is running in sandbox mode, which prevents the evaluation of potentially unsafe expressions. For more information on sandbox mode, search for "sandbox mode" in Help.

Returns an Integer representing the attributes of a file, directory, or folder.

Syntax

GetAttr ( pathname )

The required pathnameargument is a string expression that specifies a file name. The pathname may include the directory or folder, and the drive.

Return Values

The value returned by GetAttr is the sum of the following attribute values:

Constant

Value

Description

vbNormal

0

Normal.

vbReadOnly

1

Read-only.

vbHidden

2

Hidden.

vbSystem

4

System file. Not available on the Macintosh.

vbDirectory

16

Directory or folder.

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.


Note: These constants are specified by Visual Basic for Applications. The names can be used anywhere in your code in place of the actual values.

Remarks

Note: Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.

To determine which attributes are set, use the And operator to perform a bitwise comparison of the value returned by the GetAttr function and the value of the individual file attribute you want. If the result is not zero, that attribute is set for the named file. For example, the return value of the following And expression is zero if the Archive attribute is not set:

Result = GetAttr(FName) And vbArchive

A nonzero value is returned if the Archive attribute is set.

Example

This example uses the GetAttr function to determine the attributes of a file and directory or folder. On the Macintosh, only the constants vbNormal, vbReadOnly, vbHidden and vbAlias are available.

Dim MyAttr
' Assume file TESTFILE has hidden attribute set.
MyAttr = GetAttr("TESTFILE") ' Returns 2.
' Returns nonzero if hidden attribute is
' set on TESTFILE.
Debug.Print MyAttr And vbHidden
' Assume file TESTFILE has hidden and
' read-only attributes set.
MyAttr = GetAttr("TESTFILE") ' Returns 3.
' Returns nonzero if hidden attribute is
' set on TESTFILE.
Debug.Print MyAttr And (vbHidden + vbReadOnly)
' Assume MYDIR is a directory or folder.
MyAttr = GetAttr("MYDIR") ' Returns 16.

7 comments:

  1. Your blog is loaded up with extraordinary great articles! I was dazzled by how well you offer your viewpoints and sharing your experiences. I never lamented any second that went to your blog. we offers the services top r&d tax credit specialists. So you can go through our website - R&D Tax Incentive specialists

    ReplyDelete
  2. Your blog is loaded up with extraordinary great articles! I was dazzled by how well you offer your viewpoints and sharing your experiences. I never lamented any second that went to your blog. we have best quality agricultural product organic magnesium. So you can go through our website - organic fertilizer for garden

    ReplyDelete
  3. https://ferraricars77.blogspot.com/2016/10/no-root-version-of-toggle-mod-v101-bugs.html?showComment=1634719839802#c6420073459113617696

    ReplyDelete
  4. Your blog is loaded up with extraordinary great articles! . we provide you with Australia's best and most advanced harvester Cross Auger Kits. So you can go through our website - auger extensions

    ReplyDelete
  5. Your blog is loaded up with extraordinary great articles! . we offer the best service in Australia's Mediation Services. So you can go through our website - divorce lawyers sunshine coast

    ReplyDelete
  6. Your blog is loaded up with extraordinary great articles! . we offer the best service in Australia's Luxury apartment brisbane riverfront. So you can go through our website - Maroochydore Luxury Accommodation

    ReplyDelete
  7. watch all spanish daramas here in HD quality ·estrenos doramas

    ReplyDelete