FileAttr function
Returns a Long representing the file mode for files opened by using the Open statement.
Syntax
FileAttr(filenumber, returntype)
The FileAttr function syntax has these named arguments:
Part | Description |
---|---|
filenumber | Required; Integer. Any valid file number. |
returntype | Required; Integer. Number indicating the type of information to return. Specify 1 to return a value indicating the file mode. On 16-bit systems only, specify 2 to retrieve an operating system file handle. Returntype 2 is not supported in 32-bit systems and causes an error. |
Return values
When the returntype argument is 1, the following return values indicate the file access mode:
Mode | Value |
---|---|
Input | 1 |
Output | 2 |
Random | 4 |
Append | 8 |
Binary | 32 |
Example
This example uses the FileAttr function to return the file mode and file handle of an open file. The file handle is returned only on 16-bit systems; on 32-bit systems, passing 2 as a second argument generates an error.
Dim FileNum, Mode, Handle
FileNum = 1 ' Assign file number.
Open "TESTFILE" For Append As FileNum ' Open file.
Mode = FileAttr(FileNum, 1) ' Returns 8 (Append file mode).
Handle = FileAttr(FileNum, 2) ' Returns file handle.
Close FileNum ' Close file.
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기