WD2002: Sample Macro to List All Files in a Folder (306248)
The information in this article applies to:
This article was previously published under Q306248 For a Microsoft Word 2000 version of this article, see 236162.
SUMMARY
This article contains a sample Microsoft Visual Basic for Applications macro that you can use 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 for the listed files
- The file names of the files found
- The file sizes of the files found
- The dates and times 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:
290140
OFFXP: How to Run Sample Code from Knowledge Base Articles
For additional information about getting help with Visual Basic forApplications, click the article number below
to view the article in the Microsoft Knowledge Base:
305326 OFFXP: Programming Resources for Visual Basic for Applications
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbhowto kbmacroexample kbProgramming KB306248 |
---|
|