WorkbookBase.ExportAsFixedFormat Method

Definition

Saves a workbook in PDF or XPS format.

public void ExportAsFixedFormat (Microsoft.Office.Interop.Excel.XlFixedFormatType type, object filename, object quality, object includeDocProperties, object ignorePrintAreas, object from, object to, object openAfterPublish, object fixedFormatExtClassPtr);
member this.ExportAsFixedFormat : Microsoft.Office.Interop.Excel.XlFixedFormatType * obj * obj * obj * obj * obj * obj * obj * obj -> unit
Public Sub ExportAsFixedFormat (type As XlFixedFormatType, Optional filename As Object, Optional quality As Object, Optional includeDocProperties As Object, Optional ignorePrintAreas As Object, Optional from As Object, Optional to As Object, Optional openAfterPublish As Object, Optional fixedFormatExtClassPtr As Object)

Parameters

type
XlFixedFormatType

One of the Microsoft.Office.Interop.Excel.XlFixedFormatType values that specifies whether to save the workbook in PDF or XPS format.

filename
Object

The full path of the new PDF or XPS file. If you omit this parameter, Excel saves the file in the current folder.

quality
Object

One of the Microsoft.Office.Interop.Excel.XlFixedFormatQuality values that specifies the quality of the exported file.

includeDocProperties
Object

true to include document properties in the exported file; otherwise, false.

ignorePrintAreas
Object

true to ignore any print areas set when exporting; otherwise, false.

from
Object

The number of the page at which to start exporting. If this parameter is omitted, exporting starts at the beginning.

to
Object

The number of the last page to export. If this parameter is omitted, exporting ends with the last page.

openAfterPublish
Object

true to open the new file after exporting the workbook; otherwise, false.

fixedFormatExtClassPtr
Object

A pointer to an implementation of the IMsoDocExporter interface that enables the workbook to be saved in a different fixed format. For more information, see Extending the Office (2007) Fixed-Format Export Feature.

Examples

The following code example saves the first page of the workbook in PDF format to the specified file path using high-quality resolution.

This example is for a document-level customization.

private void SaveAsPDF()
{                        
    this.ExportAsFixedFormat(
        Excel.XlFixedFormatType.xlTypePDF,
        @"c:\myWorkbook",
        Excel.XlFixedFormatQuality.xlQualityStandard,
        true,
        true,
        1,
        1,
        false);
}
Private Sub SaveAsPDF()
    Me.ExportAsFixedFormat( _
        Excel.XlFixedFormatType.xlTypePDF, _
        "c:\myWorkbook", _
        Excel.XlFixedFormatQuality.xlQualityStandard, _
        True, _
        True, _
        1, _
        1, _
        False)
End Sub

Remarks

You can save as a PDF or XPS file from Microsoft Office Excel only after you install an add-in that provides this feature. For more information, search for "Enable support for other file formats, such as PDF and XPS" on Office Online.

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to