VBA File and Directory Function

VBA File and Directory Functions

VBA File and Directory Functions:

VBA File and Directory Functions can be use to handle with files, folders and directories. These are ChDir, ChDrive, CurDir, Dir, FileAttr, FileCopy, FileDateTime, FileLen, GetAttr, Kill, MkDir, Name, RmDir, SetAttr etc. These functions are Built-In functions. We can use these VBA File and Directory functions in either procedure or function. These functions we use in the VBA editor window in Excel. These File and Directory functions you can use any number of times in VBA macro codes.

List of File and Directory Functions in Excel VBA:

Here are the list of File and Directory functions. And also find its description, syntax and return type. We can use these multiple File and Directory functions in one statement.

Function Description Syntax Return Type
VBA ChDir VBA ChDir function changes the current folder or directory. ChDir(Path) N/A
VBA ChDrive VBA ChDrive function changes the current drive. ChDrive(Drive) N/A
VBA CurDir VBA CurDir function returns the current path. CurDir([Drive]) String
VBA Dir VBA Dir function returns the first name of a file or directory that matches a pattern. Dir([PathName],[Attribute]) String
VBA FileAttr VBA FileAttr function returns the file mode for opened files using the open statement. FileAttr(FileNumber,[Return]) Long
VBA FileCopy VBA FileCopy function copies a file from the source directory to the destination directory. FileCopy(Source,Destination) N/A
VBA FileDateTime VBA FileDateTime function returns the date and time when a file or directory was created or last modified. FileDateTime(PathName) Date
VBA FileLen VBA FileLen function returns the size / length of a file in bytes. FileLen(PathName) Long
VBA GetAttr VBA GetAttr function returns the attributes of a file or directory. GetAttr(PathName) Integer
VBA Kill VBA Kill function deletes a file based on the specified Path Name. Kill(PathName) N/A
VBA MkDir VBA MkDir function creates a new folder or directory . MkDir(Path) N/A
VBA Name VBA Name function moves the file to the new directory or folder. Name() N/A
VBA RmDir VBA RmDir function removes an existing directory or folder. RmDir(Path) N/A
VBA SetAttr VBA SetAttr function sets the attributes of a file or directory. SetAttr(PathName,Attributes) N/A

* N/A- Not Applicable

List of VBA Functions:

Please click on below link to go back to see all List of VBA Functions.

Quick View of VBA File & Directory Functions List of VBA Functions

Leave a Comment

Your email address will not be published. Required fields are marked *