The Filename attribute can contain paths in addition to filenames. For example, if you want to create employee records in a file named employee.dat on a floppy diskette, you could use the following syntax.

Open "a:\employee.dat" For Output As #1

The result of the Open function varies depending on the initial action chosen. If the Input parameter is chosen, the Open function searches for the file and creates a buffer in memory. If the file is not found, VBA generates an error.

T«*»c,t A buffer ¡s an area where data ¡s temporarily stored.

If the file specified is not found, a new file is created using the Filename parameter as the filename. Note that the Output mode always overwrites an existing file. Once a data file has been successfully opened, you can then read from it, write to it, and close it.

0 0

Post a comment