File Related Functions

VBA has a large number of functions related to file and directory housekeeping. Table 8-1 contains a selection of them.

Table 8-1. Some VBA File and Directory Functions

Function

Description

Dir

Find a file with a certain name.

FileLen

Get the length of a file.

FileTimeDate

Get the date stamp of a file.

FileCopy

Copy a file.

Kill

Delete a file.

Name

Rename a file or directory.

RmDir

Delete a directory.

MkDir

Make a new directory.

In addition to the file-related functions in Table 8-1, there may be times when it is useful to create new text files to store data. VBA provides a number of functions for this purpose, headed by the Open statement, whose (simplified) syntax is:

Open pathname For mode As [#] filenumber

Once a file has been opened, we can read or write to it.

0 0

Post a comment