DoCmd Object.
The OutputTo method carries out the OutputTo action in Visual Basic. For more information on how the action and its arguments work, see the action topic.
DoCmd.OutputTo objecttype [, objectname] [, outputformat] [, outputfile] [,autostart]
The OutputTo method uses the following arguments.
Argument |
Description |
objecttype |
One of the following intrinsic constants: |
acTable | |
objectname |
A string expression that is the valid name of an object of the type selected with the objecttype argument. If you want to output the active object, specify the object’s type for the objecttype argument and leave this argument blank. If you execute Visual Basic code containing the OutputTo method in a library database, Microsoft Access looks for the object with this name first in the library database, then in the current database. |
outputformat |
One of the following intrinsic constants: |
acFormatXLS | |
If you leave this argument blank, Microsoft Access prompts you for the output format. |
Argument |
Description |
outputfile |
A string expression that is the full name, including the path, of the file you want to output the object to. If you leave this argument blank, Microsoft Access prompts you for an output file name. |
autostart |
Use True (-1) to start the appropriate Windows-based application immediately, with the file specified by outputfile loaded. Use False (0) if you don’t want to start the application. If you leave this argument blank, the default (False) is assumed. |
Modules can be output only in MS-DOS Text format, so if you specify acModule for objecttype, you must specify acFormatTXT for outputformat.
You can leave an optional argument blank in the middle of the syntax, but you must include the argument’s comma. If you leave a trailing argument blank, don’t use a comma following the last argument you specify.
DoCmd Object, OutputTo Action, SendObject Method.
This example outputs the Employees table in rich-text format (.rtf) to the Employee.rtf file and immediately opens the file in Microsoft Word for Windows.
DoCmd.OutputTo acTable, "Employees", acFormatRTF, "Employee.rtf", True