Article ID: 236162 - Last Review: October 11, 2006 - Revision: 3.2 WD2000: Sample Macro to List All Files in a Folder
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:
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. MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
The following sample macro lists or prints the file name, the file size, and the date/time of all files found in the specified folder:
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
(http://support.microsoft.com/kb/212536/EN-US/
)
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
(http://support.microsoft.com/kb/226118/EN-US/
)
OFF2000: Programming Resources for Visual Basic for Applications
| Other Resources Other Support Sites
CommunityGet Help NowArticle Translations
|






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email
Back to the top
