These days, it is not likely that you would want to export Access data to a Lotus spreadsheet or a
dBASE database, but there is still a need to export comma-delimited or fixed-width text files, so the
TransferTextmethod is also useful for exporting data from Access to text files.
Working with Text Files Using the TransferText Method....................................................
When you use the TransferTextmethod in VBA code, you can supply a specification name. A
specification for an import or export is created when you run the export or import manually. The
process of creating a specification (and reusing it in the interface) has been streamlined in Access
2007; I cover the creation of an export specification in the next section. Specifications are handy
when you need to set a number of custom options for an export or import, especially if you plan to
re-run the export or import in the interface; however, they are not required.
Creating an Import or Export Specification..............................................................
The process of creating an import specification for importing a fixed-width text file is described next;
you create specifications for importing a comma-delimited text file, or exporting either of those file
types, in a similar manner, with different options depending on the file type. You might want to use
an import specification, for example, if you receive a text file of comma-delimited data downloaded
from a mainframe every week, and you need to import the weekly data into an Access table.
- First, click the Text File button on the External Data menu, as shown in Figure 10.1.
FIGURE 10.1
Starting an import of a text file.
- Next, in the Get External Data - Text File dialog box (shown in Figure 10.2), use the
Browse button to select the text file to import (Jobs 02-Jul-2006.txt in the example).
Part II Writing VBA Code to Exchange Data between Office Components