Microsoft Office Tutorials and References
In Depth Information
Chapter 13
Manipulating Files
Locating External Files . . . . . . . . . . . . . 281
Reading from an External File . . . . . . . . 296
Writing to an External File . . . . . . . . . . 295
Searching a File for a Value . . . . . . . . . . 298
Many applications that you develop for Microsoft Excel require working with multiple files.
For example, you might need to get a listing of files in a directory, delete files, or rename files.
Excel, of course, can import and export several types of text files. In many cases, however,
Excel’s built-in text file handling is not sufficient. For example, you might need to import a
text file that contains more than 256 columns of data, which is Excel’s limit, or the file might
use a nonstandard delimiter such as a backward slash (\).
In this chapter, you’ll learn how to locate, write to, and read from external files. You’ll also
learn to narrow your search using wildcards, as well as to search files for specific values.
Locating External Files
The Office Object Model is made available to all Microsoft Office applications, as discussed
in previous chapters. It contains objects that are used by all Office applications, such as the
CommandBars object, which is discussed in Chapter 17. You’ll learn how to utilize two
objects contained in the Office Object Model that you use to search for files: FileSearch and
FileDialog . You’ll also evaluate the following objects associated with each object.
The following files are associated with the FileSearch object:
FoundFiles
FileTypes
SearchScopes
ScopeFolders
SearchFolders
The following files are associated with the FileDialog object:
FileDialogFilters
FileDialogSelectedItems
The FileSearch object allows you to search for files with a wide range of search criteria. You are
able to search by file type, file size, file location, and date of last modification. The FileSearch
object places the names of the files it finds in the FoundFiles collection.
Search JabSto ::




Custom Search