Excel VBA Macros | Referencing other applications exercise | Using FileSystemObjects to manipulate files

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

Software ==> Excel VBA Macros  (52 exercises)
Version ==> Any version of Excel
Topic ==> Referencing other applications  (2 exercises)
Level ==> Average difficulty
Subject ==> VBA training
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

The folder shown above contains a number of files, some of which are Excel workbooks.

Create a macro to loop over all of the files in the folder.  Your macro should:

  • Check for each file whether it is an Excel workbook (ie use the RIGHT function to check whether the right-most 3 or 4 characters of the file name are XLS or XLSX, depending on your Excel version)
  • Open up the workbook with the given path
  • Write your name into cell B2
  • Close the workbook back down, saving any changes

If you can't remember how to open and close workbooks - record a macro!

When you have got the macro to work, save it as Signing workbooks, then close it down.

If you want another challenge, given the files in the folder above, create a macro in a new workbook which:

  • Creates a new folder on your C drive with a name of your choice, if it doesn't already exist
  • Copies all of the TXT files shown above into this folder
  • Deletes the file called Po.txt
  • Renames Laa Laa.txt to Yellow teletubbie.txt

Save this workbook as Various file tasks, then close it down.

You can unzip this file to see the answers to this exercise, although please remember this is for your personal use only.
This page has 0 threads Add post