WD2000: Sample Macro to List All Files in a Folder (236162)
The information in this article applies to:
This article was previously published under Q236162 SUMMARY
This article contains a sample Microsoft Visual Basic for Applications macro that can be used to create a list of all files in a specified folder. The macro returns the following information to a new Word document:
- The folder name of the listed files.
- The file name of the files found.
- The file size of the files found.
- The date and time of the files found.
- The total number of files listed.
The macro creates a list of files similar to the following example:
File Listing of the C:\MY DOCUMENTS folder!
File Name File Size File Date/Time
----------------------------------------------------------------------
Background.doc 1461 2/24/99 2:16:52 PM
Backup of Background.wbk 1461 2/24/99 2:14:10 PM
Book1.xls 15360 6/15/99 3:07:42 PM
Book2.xls 13824 11/12/98 4:28:50 PM
Book3.xls 13824 11/24/98 9:38:32 AM
Total files in folder = 5 files.
REFERENCES
For more information about how to use the sample code in this article, click
the article number below to view the article in the Microsoft Knowledge
Base:
212536
OFF2000: How to Run Sample Code from Knowledge Base Articles
For additional information about getting help with Visual Basic for
Applications, please see the following article in the Microsoft Knowledge Base:
226118 OFF2000: Programming Resources for Visual Basic for Applications
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbhowto kbmacroexample kbProgramming KB236162 |
---|
|