OutputTo Method

Microsoft Access Visual Basic

action in Visual Basic.

expression.OutputTo(ObjectType, ObjectName, OutputFormat, OutputFile, AutoStart, TemplateFile, Encoding)

expression    Required. An expression that returns a DoCmd object.

ObjectType   Required AcOutputObjectType. The type of object to output.

AcOutputObjectType can be one of these AcOutputObjectType constants.
acOutputDataAccessPage Not supported.
acOutputForm
acOutputFunction
acOutputModule
acOutputQuery
acOutputReport
acOutputServerView
acOutputStoredProcedure
acOutputTable

ObjectName   Optional Variant. A string expression that's the valid name of an object of the type selected by 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 run 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   Optional Variant. The output format, expressed as an AcFormat constant. If you omit this argument, Microsoft Access prompts you for the output format.

AcFormat can be one of these AcFormat constants.
acFormatASP
acFormatDAP
acFormatHTML
acFormatIIS
acFormatRTF
acFormatSNP
acFormatTXT
acFormatXLS

OutputFile   Optional Variant. A string expression that's 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   Optional Variant. Use True (–1) to start the appropriate Microsoft Windows–based application immediately, with the file specified by the OutputFile    argument loaded. Use False (0) if you don't want to start the application. This argument is ignored for Microsoft Internet Information Server (.htx, .idc) files and Microsoft ActiveX Server (*.asp) files. If you leave this argument blank, the default (False) is assumed.

TemplateFile   Optional Variant. A string expression that's the full name, including the path, of the file you want to use as a template for an HTML, HTX, or ASP file.

Encoding   Optional Variant.

Remarks

For more information on how the action and its arguments work, see the action topic.

Modules can be output only in MS-DOS Text format, so if you specify acOutputModule for the ObjectType argument, you must specify acFormatTXT for the OutputFormat argument. Microsoft Internet Information Server and Microsoft ActiveX Server formats are available only for tables, queries, and forms, so if you specify acFormatIIS or acFormatASP for the OutputFormat argument, you must specify acOutputTable, acOutputQuery, or acOutputForm for the ObjectType argument.

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.

Example

The following 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 acOutputTable, "Employees", _
    acFormatRTF, "Employee.rtf", True