The information in this article applies to:
SUMMARYThis article demonstrates the Microsoft WordBasic Files$() function. This function can be used to assemble a list of file names within a directory. The Files$() function returns the first file name that matches the specified file specification (for example: *.* or *.doc). If you specify a file specification on the first iteration and then omit it thereafter, you can generate a list of files. MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/supportnet/refguide/The following sample macro inserts the file names from the current directory into a new document window:
To insert only the file names with a ".doc" extension, change "*.*" to
"*.doc" in the above example.
The following macro example determines how many files are in the current directory and defines an array named List$() to hold the file names. Because the Files$() function returns the file names with the full path (for example, C:\Document.doc), the FileNameInfo$() function is used to extract just the file names which are then assigned to elements within the List$() array.
Note to Macintosh users: The third line of the macro which reads
should be replaced with the following line
where <TYPE> is the file type. For example: "TEXT", "W6BN", etc.
NOTE: The disk that accompanies the "Microsoft Word Developer's Kit," includes a macro that allows you to browse through files in any directory. The macro uses a dynamic dialog box to display a file and directory list similar to Word's Open dialog box. The macro is named ch05ex06FileBrowser and is located in the Examples.dot file. REFERENCES"Microsoft Word Developer's Kit," version 6.0, pages 128-130 Additional query words: Files$() Array List File Name FileName print
Keywords : kbmacro wordnt kbmacroexample winword ntword macword word6 word7 word95 |
Last Reviewed: December 28, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |