Close statement
Concludes input/output (I/O) to a file opened by using the Open statement.
Syntax
Close [ filenumberlist ]
The optional filenumberlist argument can be one or more file numbers that use the following syntax, where filenumber is any valid file number: [[ # ] filenumber ] [ , [ # ] filenumber ] . . .
Remarks
If you omit filenumberlist, all active files opened by the Open statement are closed.
When you close files that were opened for Output or Append, the final buffer of output is written to the operating system buffer for that file. All buffer space associated with the closed file is released.
When the Close statement is executed, the association of a file with its file number ends.
Example
This example uses the Close statement to close all three files opened for Output.
Dim I, FileName
For I = 1 To 3 ' Loop 3 times.
FileName = "TEST" & I ' Create file name.
Open FileName For Output As #I ' Open file.
Print #I, "This is a test." ' Write string to file.
Next I
Close ' Close all 3 open files.
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 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기