File – 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.

We use these functions to create,delete, or rename folders. Store files in created folders. You can organize files, folders and directories.

Click on the following link to learn VBA File and Directory Functions in Excel.

VBA File and Directory Functions in Excel

VBA Remove Directory and its Content

VBA Remove Directory and its Content

VBA Remove Directory and its Content VBA Remove specified directory and its content. In the following tutorial we have explained step by step instructions to run example macro. Table of Contents: Overview on Removing Directory and its Content using VBA VBA Removing Directory and its Content Instructions to use VBA Macro Code Related Articles VBA …

VBA Remove Directory and its ContentRead More »

VBA Count Files in Folder and Subfolders

VBA Count Files in Folder and Subfolders

VBA Count Files in Folder and Subfolders VBA Count Number of Files in Folder and Subfolders. We are checking main folder and all the other available subfolders to count number of files. We use recursive method to check each and every subfolder. In the following tutorial we have explained step by step instructions to run …

VBA Count Files in Folder and SubfoldersRead More »

VBA Delete Empty Subfolders

VBA Delete Blank Subfolders

VBA Delete Empty Subfolders VBA Delete Empty Subfolders from a specified folder using VBA. First we are checking subfolder has files in it. Files are available we are not deleting that respective subfolder. If files are not available and now subfolder is empty then we are deleting that folder. In the following tutorial we have …

VBA Delete Empty SubfoldersRead More »

VBA Delete Empty Folder

VBA Delete Empty Folder

VBA Delete Empty Folder VBA Delete Empty Folder in Excel. We use VBA RmDir VBA function to delete only blank or empty folder. It throws an error, If any file exists in the specified folder. The following tutorial explains examples and step by step instructions for user reference. Table of Contents: Overview on deleting empty …

VBA Delete Empty FolderRead More »

VBA Delete File

VBA Delete File

VBA Delete File VBA Delete File from a folder or directory in Excel. You can delete any file like Excel, Word, PowerPoint, CSV, Notepad etc. Let us see different examples in the following tutorial. We are using Kill statement to delete a file. Table of Contents: Overview on deleting file in Excel Example on Deleting …

VBA Delete FileRead More »

VBA Delete All Files in Folder and Subfolders

VBA Delete Files in Folder and Subfolder

VBA Delete All Files in Folder and Subfolders VBA Delete All Files in Folder and Sub folders in Excel. In the following tutorial we are using recursive method. It is nothing but looping through all folders until finishes all available folders. Let us see an example macro code to delete files in folders and sub …

VBA Delete All Files in Folder and SubfoldersRead More »

VBA Check If Folder Exists If Not Create It

VBA Check If Folder Exists If Not Create It

VBA Checking If Folder Exists If Not Create It VBA Check If Folder Exists If Not Create It in specified name using VBA in Excel. We are using 2 methods to check folder exists or not. Those are Dir VBA function and FileSystemObject object. In the following tutorial let us see an example macro code. …

VBA Check If Folder Exists If Not Create ItRead More »

VBA Check If File Exists If Not Create It

VBA Check If File Exists If Not Create It

VBA Check If File Exists If Not Create It VBA check If File Exists or not. If not create a new file with specified name using VBA in Excel. We are using 2 methods to check folder exists or not. Those are Dir VBA function and FileSystemObject object. In the following tutorial let us see …

VBA Check If File Exists If Not Create ItRead More »

VBA Delete All Files and Subfolders from a Folder

VBA Delete All Files and Subfolders

VBA Delete All Files and Subfolders VBA Delete all Files and Subfolders form a specified folder using Excel VBA. You can delete all files using DeleteFile method of FileSystemObject. And delete all folders using DeleteFolder method of FileSystemObject. Table of Contents: Overview Delete All Files and Subfolders in a Folder using Excel VBA Example Instructions …

VBA Delete All Files and Subfolders from a FolderRead More »

VBA Delete All Files in a Folder

VBA Delete All Files in a Folder

VBA Delete All Files in a Folder Deleting all Files in a Folder in Excel using VBA. If folder is empty, then no file is avilable to delete. In the following tutorial we have explained with example and step by step instructions for user reference. Table of Contents: Overview on Deleting Files in a Folder …

VBA Delete All Files in a FolderRead More »

VBA Check If File Exits then Delete

VBA Check If File Exits then Delete

VBA Check If File Exits then Delete Check If File Exits in the specified folder in Excel VBA. If it is available then Delete file from the specified folder. In the following tutorial we have explained step by step instructions. Table of Contents: Overview on Checking if file exists VBA Checking If File Exits then …

VBA Check If File Exits then DeleteRead More »

Create Microsoft Scripting Runtime Reference

Microsoft Scripting Runtime Reference

Create Microsoft Scripting Runtime Reference Create Microsoft Scripting Runtime Library Reference. Here are the instructions to add reference before running below VBA macro code. Table of Contents: Overview Step by step instructions to add Microsoft Scripting Runtime Library reference Create FSO Object VBA FSO Auto List Members Enable VBA FSO Auto List Members Step by …

Create Microsoft Scripting Runtime ReferenceRead More »

VBA Loop Through XLAM Files in a Folder

VBA Loop Through XLAM Files in a Folder

VBA Loop Through XLAM Files in a Folder VBA Loop Through xlam Files in a Folder using built-in Dir() function. In this tutorial we loop through a folder or directory and list all available .xlam files in a folder. Lets learn how to use Dir, Right and Len VBA functions in this tutorial. Table of …

VBA Loop Through XLAM Files in a FolderRead More »

VBA Loop Through TXT Files in a Folder

VBA Loop Through TXT Files in a Folder

VBA Loop Through all TXT Files in a Folder VBA Loop Through all TXT Files in a Folder using built-in Dir() function. In this tutorial we loop through a folder or directory and list all available .TXT files in a folder. Lets learn how to use Dir, Right and Len VBA functions in this tutorial. …

VBA Loop Through TXT Files in a FolderRead More »

VBA Loop Through all XML Files in a Folder

VBA Loop Through all XML Files

VBA Loop Through all XML Files in a Folder VBA Loop Through all XML Files in a Folder using built-in Dir() function. In this tutorial we loop through a folder or directory and list all available .XML files in a folder. Lets learn how to use Dir, Right and Len VBA functions in this tutorial. …

VBA Loop Through all XML Files in a FolderRead More »