FileSystemObject : MoveFile Method

Description: 

This function moves a file from one location to another.

Format : 

objectOfFileSystemObject. MoveFile (source, destination);

Arguments: 
  • objectOfFileSystemObject : As the name says, it’s a FileSystemObject.

As the name says, it’s a FileSystemObject.

FileSystemObject:OpenTextFile Method

FileSystemObject:OpenTextFile Method

Description :

This function opens a file and returns a TextStream object and later you can use that TextStream object to perform various activities on that file like reading or writing

Format :

objectOfFileSystemObject. OpenTextFile(filename[, iomode[, create[, format]]])

Arguments: 

FileSystemObject : CreateTextFile Method

Description: 

This function creates a file and returns a TextStream object and later you can use that TextStream object to perform various activity on that file like reading or writing

Format :

objectOfFileSystemObject. CreateTextFile (filename[, overwrite[, unicode]])

  • objectOfFileSystemObject : As the names says, it’s a FileSystemObject.
Arguments: 
    • filename
      • Mandatory
      • Type:     String
      • File will be created with the same name what you will pass here.

    Read moreFileSystemObject : CreateTextFile Method

    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.

    Read moreFileSystemObject in Excel Macro

    Password Protection to Your Macro Code

    In earlier sessions we saw that how we can write code, generate code and customize it but at the same time it’s very essential to protect it. Excel provides an option to make our Code password protected.

    In Next few steps we will see how to make our macro secure.

    Step 1:

     In VB Editor, right click on the “VBAProject(Book1)” in Project window and select “VBA Project Properties..”

    Excel-VBA-MACRO - Password Protection To Macro - 1
    Excel-VBA-MACRO – Password Protection To Macro – 1

    “Project Properties” window will be displayed.

    Read morePassword Protection to Your Macro Code