FileSystemObject (FSO)

The FileSystemObject (FSO) provides access to file system. It has different methods and properties. It returns TextStream object.

The FSO has following methods: BuildPath, CopyFile, CopyFolder, CreateFolder, CreateTextFile, DeleteFile, DeleteFolder, DriveExists, FileExists, FolderExists, GetAbsolutePathName, GetBaseName, GetDrive, GetDriveName, GetExtensionName, GetFile, GetFileName, GetFolder, GetParentFolderName, GetSpecialFolder, GetTempName, Move, MoveFile, MoveFolder, OpenAsTextStream, OpenTextFile, and WriteLine.

The FSO has following Properties: Drives, Name, Path, Size, and Type.

VBA Create Folder with Today’s Date

VBA Create Folder with Today's Date

VBA Create Folder with Today’s Date VBA Create Folder with Today’s or current Date. Today’s date is 3rd Oct 2019. We are checking specified folder is already exists in the specified folder. If it is not available then we are creating new folder using MkDir VBA function. The folder name always displays system current date. …

VBA Create Folder with Today’s Date Read More »

VBA Create Folder on Desktop

VBA Create Folder on Desktop

VBA Create Folder on Desktop VBA Create Folder on Desktop. In the below specified example we are using the Environment variable UserProfile to find the desktop location. You can change the folder path which you want to create on the desktop according to your requirement. We are checking specified folder is already exists on the …

VBA Create Folder on Desktop Read More »

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 Content Read 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 Subfolders Read 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 Subfolders Read 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 Folder Read 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 File Read 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 Subfolders Read 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 It Read 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 It Read 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 Folder Read 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 Folder Read 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 Delete Read More »

VBA Delete Text Files

VBA Delete Text Files

VBA Delete Text Files VBA Delete Text Files using Kill statement or DeleteFile method of file system object(FSO). In the following tutorial let us learn how to delete text file in two different methods. Table of Contents: Overview of Delete Text File in Excel VBA Add Reference: Microsoft scripting Runtime DeleteFile Method to Delete Text …

VBA Delete Text Files Read 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 Reference Read More »