Microsoft Office Tutorials and References
In Depth Information
Getting a List of Filenames
Getting a List of Filenames
You might think that putting a list of filenames into a worksheet range would be fairly
straightforward: Just instruct Windows to generate a list of files for a directory and then import the list
into an Excel worksheet. Unfortunately, it’s not that easy. Many users are surprised to discover
that Windows doesn’t provide a direct way to export a list of filenames to a file.
Perhaps the best solution is to write a VBA macro to create a list of files. The method described
here doesn’t require a macro. However, it does require that you go back in time and use an
oldfashioned command line interface.
The following instructions assume that you want to generate a list of files contained in a directory
named upper :
1. Click the Windows Start button and choose Run.
2. In the Run dialog box, type cmd and click OK.
This step displays the Windows command shell.
If you don’t see the Run command, type cmd in the search box.
3. Navigate to the directory that you’re interested in by typing cd , followed by the full path.
In this example, enter this line:
cd c:\my files\excel
4. Type the following command and press Enter:
dir > filelist.txt
Figure 181-1 shows what the command prompt window looks like as you work through the
preceding set of steps.
Figure 181-1: Using the Windows command prompt to generate a list of files.
 
Search JabSto ::




Custom Search