Partager via


Visual Basic Reference

ExportReport Method

See Also    Example    Applies To

Exports the text of a report to a file using a specified ExportFormat object. Images and shapes cannot be exported.

Syntax

object.ExportReport(ExportFormat, filename, Overwrite, ShowDialog, Range, PageFrom, PageTo)

The ExportReport method syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
ExportFormat Optional. The ExportFormat object to be used. The argument can be an object reference, or a string key that specifies one of the members of the ExportFormats collection as shown in Settings.

If not specified, the Export dialog box will display.

filename Optional. A string expression that evaluates to the name of the file. If not specified, the Export dialog box will display.
overwrite Optional. A boolean expression that determines if the file will be overwritten.
showDialog Optional. A boolean expression that determines if the Save As dialog box will be displayed. If no ExportFormat object or filename is specified, the Export dialog box will be displayed, even if this argument is set to False.
Range Optional. Sets an integer that determines if all the pages in the report will be executed, or a range of pages, as shown in Settings.
PageFrom Optional. A numeric expression that specifies the page where the export will start.
PageTo Optional. A numeric expression that specifies the page where the export will end.

Settings

The settings for ExportFormat are:

Constant Value Description
rptKeyHTML key_def_HTML Specifies the HTML default member of the ExportFormats collection.
rptKeyUnicodeHTML key_def_UnicodeHTML_UTF8 Specifies the Unicode HTML default member of the ExportFormats collection
rptKeyText key_def_Text Specifies the text default member of the ExportFormats collection
rptKeyUnicodeText key_def_UnicodeText Specifies the Unicode text default member of the ExportFormats collection

When adding an ExportFormat object to the ExportFormats collection, you must specify a Key for the object. That key can be used in the ExportFormat argument.

The settings for Range are:

Constant Value Description
rptRangeAllPages 0 (Default) All pages will be printed.
rptRangeFromTo 1 Only the specified range of pages will be exported.

Return Value

Long

Remarks

If all necessary arguments are not supplied with the method, a dialog box is displayed, prompting the user for appropriate information (such as filename).

The ExportReport method performs an asynchronous operation. The method returns the identifier of the "cookie" that identifies the asynchronous operation.

Important   The range of pages specified will not match the pages seen in the Print Preview mode. Whereas export page numbers are based on font attributes of the ExportFormat object's ExportType property, print and preview pages are based on the current printer object used by the computer.