Be the first user to complete this post

  • 0
Add to List

FileSystemObject in Excel Macro

The FileSystemobject act as an mediator for your code and computer’s system files. Once you create the object of FileSystemObject, using that object you can perform various operations on your computer like create creating folders, textfiles, reading them, deleting them etc.

Create object of FileSystemObject.

Dim fso As New FileSystemObject

Make sure the “Microsoft Scripting Rumtime” reference is added to your workbook (Excel). To know more about adding a reference library

OR

If you doesn’t want to add library to your excel then use the full name ( refLibName.Object), its same as in java when you import a package you can directly use the classes inside the package else you have to use full class name which is packagename.classname.

Set fso = CreateObject("Scripting.FileSystemObject")

So here “Scripting” is a library name followed by “FileSystemObject”

Please check following methods of FileSystemObject

CopyFile Method
CopyFolder Method
CreateFolder Method
CreateTextFile Method
DeleteFile Method
DeleteFolder Method
DriveExists Method
FileExists Method
FolderExists Method
GetAbsolutePathName Method
GetDriveName Method
GetExtensionName Method
GetFile Method
GetFileVersion Method
GetFolder Method
GetParentFolderName Method
MoveFile Method
MoveFolder Method
OpenTextFile Method



Also Read:

  1. FileSystemObject : GetParentFolderName Method
  2. FileSystemObject:OpenTextFile Method
  3. FileSystemObject : MoveFolder Method
  4. FileSystemObject : FolderExists Method
  5. FileSystemObject : GetDriveName Method