Access.2007.VBA.Bibl..

(John Hannent) #1

I


n the previous chapter, you learned how to work with text files, using one
old method and two new ones. For some types of text files, you can also
use methods of the Access Application object for importing and exporting
text files when working with data in VBA code. The TransferTextmethod
has been used to import data from (or export data to) comma-delimited or
fixed-width files since the early days of Access, and it is still useful in Access
2007, when you are working with files in these formats. In Office XP, the
TransferTextmethod was updated to also export to and import from
HTML files.

Typically, comma-delimited or fixed-width files are produced by mainframe
computers, and you may need to import these files into your Access tables or
export data from Access tables to comma-delimited or fixed-width files for
import into mainframe applications. Additionally, you can use these formats
to export data to or import data from other applications whose formats aren’t
directly supported by Access.

If you have data in Excel or Lotus spreadsheets, you can use the
TransferSpreadsheetmethod to import data from them or export data
to spreadsheets. And the TransferDatabasemethod can be used to
transfer data between Access tables and legacy databases or spreadsheets.

These three methods don’t have the power or flexibility of Automation code,
which can iterate through the records in a table, perhaps using a filtered
recordset, and write data from specific fields to a worksheet. But if you need
to import all the data from a Lotus worksheet or a dBASE database, so you
can work with it in Access, these methods come in handy.

IN THIS CHAPTER


Importing and exporting
comma-delimited and fixed-
width text files

Importing and exporting dBASE,
Paradox, and Lotus 1-2-3 files

Importing and exporting XML
and HTML files

Emailing exported text files

Working with


External Data

Free download pdf