You can use the OutputTo action to output the data in the specified Microsoft Access database object (a datasheet, form, report, or module) to a file in Microsoft Excel (.xls) version 7.0, rich-text (.rtf), or MS-DOS Text (.txt) format.
The OutputTo action uses the following arguments.
Action argument |
Description |
Object Type |
The type of object containing the data to output. Click Table (for a table datasheet), Query (for a query datasheet), Form (for a form or form datasheet), Report, or Module in the Object Type box in the Action Arguments section of the Macro window. You can’t output a macro. If you want to output the active object, select its type with this argument, but leave the Object Name box blank. The default is Table. This is a required argument. |
Object Name |
The name of the object containing the data to output. The Object Name box shows all objects in the database of the type selected by the Object Type argument. If you run a macro containing the OutputTo action in a library database, Microsoft Access looks for the object with this name first in the library database, then in the current database. |
Output Format |
The type of format you want used to output the data. You can click Microsoft Excel (*.xls), Rich Text Format (*.rtf), or MS-DOS Text (*.txt) in the box. Modules can be output only to MS-DOS Text format. If you leave this box blank, Microsoft Access prompts you for the output format. |
Output File |
The file you want to output the data to, including the full path. You can include the standard filename extension (.xls, .rtf, or .txt) for the output format you select by the Output Format argument, but it’s not required. If you leave the Output File box blank, Microsoft Access prompts you for an output filename. |
Auto Start |
Indicator whether you want the appropriate application to start immediately after the OutputTo action runs, with the file specified in the Output File argument opened. If you select Yes, one of the following applications starts with the output file from the Microsoft Access object opened: Microsoft Excel (for .xls files), Microsoft Word for Windows (for .rtf files), or Microsoft Windows Notepad (for .txt files). If you select No, the application doesn’t start. The default is No. |
The Microsoft Access data is output in the selected format and can be read by any application that uses the same format. For example, you can output a Microsoft Access report with its formatting to a rich-text format document and then open the document in Word for Windows.
The following rules apply when you use the OutputTo action to output a database object:
If you output the data in a report to an output file and the columns and rows of data in the output file do not align as in the report, the following tips may help:
The OutputTo action is similar to clicking Save As/Export on the File menu, selecting the To An External File Or Database option, and selecting the Save Formatted check box in the dialog box that is displayed. The action arguments correspond to the settings in the Save As/Export dialog boxes. The Save As/Export command, however, applies only to the object selected in the Database window. By using the OutputTo action, you can specify the object you want to output.
Note You can output the selected data with the Save As/Export command. However, this functionality is not available with the OutputTo action.
You can also point to Office Links on the Tools menu, then click Analyze It With MS Excel or Publish It With MS Word to output a database object, and open the output file immediately in Microsoft Excel or Microsoft Word for Windows.
To run the OutputTo action in Visual Basic, use the OutputTo method of the DoCmd object.
OutputTo Method, SendObject Action.