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 Delete Subfolders Older than 30 Days from a folder in Excel. In this following tutorial we are going to see how to delete files and sub-folders which are older than 30 days. Here we are checking for 30 days. You can change this number. It can be one week, one month, quarter, or year. …
VBA Delete Subfolders Older than X Days Read More »
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. We use VBA Now function to …
VBA Create Folder with Today’s Date Read More »
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 desktop. If it is not …
VBA Create Folder on Desktop Read More »
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: Objective VBA Removing Directory and its Content Instructions to Run VBA Macro Code Other Useful Resources VBA Remove Directory and its Content Let us see an example macro VBA code …
VBA Remove Directory and its Content Read More »
VBA Count Number of Files in Folder and Subfolders. We are checking main folder and all the other available sub-folders to count number of files. We use recursive method to check each and every sub folder. In the following tutorial we have explain step by step instructions to run example macro. Table of Contents: Objective …
VBA Count Files in Folder and Subfolders Read More »
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 explained step by step …
VBA Delete Empty Subfolders Read More »
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: Objective Example on VBA Blank or Empty Folder …
VBA Delete Empty Folder Read More »
VBA Delete File in Excel from a folder or directory. 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: Objective Example on Deleting different type of File using Kill Statement Deleting …
VBA Delete File in Excel Read More »
VBA Delete All Files in Folder and Subfolders 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 VBA code to delete files in folders and sub folders. You can also find the step by …
VBA Delete All Files in Folder and Subfolders in Excel Read More »
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. And also see the step by step instructions to …
VBA Check If Folder Exists If Not Create It Read More »
VBA Check If File Exists If Not Create It in Excel. 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 an example macro code. And …
VBA Check If File Exists If Not Create It Read More »
VBA Delete all Files and Subfolders form a 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 to Run VBA Macro Code Other Useful …
VBA Delete All Files and Subfolders from a Folder Read More »
VBA Delete All Files in a Folder in Excel Delete all Files in a Folder in Excel using VBA. If folder is empty, then no file is available to delete. In the following tutorial we have explained with example and step by step instructions for user reference. Table of Contents: Objective VBA Delete All Files …
VBA Delete All Files in a Folder Read More »
VBA Check If File Exits then Delete in Excel. 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: Objective VBA Checking If File Exits then Delete in Excel Instructions to Run VBA Macro Code Other Useful Resources VBA Check …
VBA Check If File Exits then Delete Read More »
VBA Delete Files over 90 Days old from a folder in Excel. In this following tutorial, we are going to see how to delete older files which can be any number of days. Here we are checking for 90 days. You can change this number. It can be one week, one month, quarter, or year. …
VBA Delete Files over 90 Days Old Read More »
VBA Check if File is Open or not using Excel VBA. In general we automate reports using Excel VBA. When we are dealing with multiple workbooks. It is always better to check whether file is opened or not. After that we can use those files for anything like data analysis, preparing reports etc. Table of …
VBA Check if File is Open Read More »
VBA Create Folder in Excel. We use MkDir VBA function to create a folder. We creates a folder in a specific directory or current directory. Once we create folder, we store file or files in it. If folder already exists then it throws an error message. In this tutorial we explained examples and step by …
VBA Create Folder Read More »
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: Objective Add Reference: Microsoft scripting Runtime DeleteFile Method to Delete Text File in Excel VBA Kill Statement to Delete Text File in …
VBA Delete Text Files Read More »
Create Microsoft Scripting Runtime Library Reference. Here are the instructions to add reference before running below VBA macro code. Table of Contents: Objective 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 Instructions to Run VBA Macro Code Other …
Create Microsoft Scripting Runtime Reference Read More »
VBA Create Text File using CreateTextFile method of file system object (FSO) and Text Files Open statement. let us see both methods in the following tutorial. Table of Contents: Objective Add Reference: Microsoft scripting Runtime Example on VBA Create Text File using FSO in Excel Example on VBA Create Text File using Open Statement Instructions …
VBA Create Text File Read More »