Need your macro to interact with every file in a specific directory? Create a directory? Copy, move, or delete a file? It’s all here.
The code that browses for a folder, which I copied from an external web site, does not work on 64 bit systems. Please use the code in the “Homework” and “Lesson Files” links below, which I have updated to work with 64 bit systems.
An alternative method for creating an open file dialog is to use Common Dialog controls. To do this you will need to right click on your toolbox and choose “Additional Control”. Then browse for Microsoft Common Dialog Control, version 6.0. Click the X to the left of the name and hit OK. Now you have the common dialog control available to you. Drag it onto your form but do not try to resize it. It will not actually be visible on your form, but now you can use the methods and properties for that control. For example, if the control is called “CommonDialog1” then you could create a dialog box to locate a file using the following:
You can modify the selection filter using the Filter property.