Workbook.Close Method (2007 System)

Closes the workbook.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
Public Sub Close ( _
    SaveChanges As Object, _
    Filename As Object, _
    RouteWorkbook As Object _
)
'Usage
Dim instance As Workbook 
Dim SaveChanges As Object 
Dim Filename As Object 
Dim RouteWorkbook As Object

instance.Close(SaveChanges, Filename, _
    RouteWorkbook)
public void Close(
    Object SaveChanges,
    Object Filename,
    Object RouteWorkbook
)
public:
void Close(
    Object^ SaveChanges, 
    Object^ Filename, 
    Object^ RouteWorkbook
)
public function Close(
    SaveChanges : Object, 
    Filename : Object, 
    RouteWorkbook : Object
)

Parameters

  • SaveChanges
    Type: System.Object

    If there are no changes to the workbook, this argument is ignored. If there are changes to the workbook and the workbook appears in other open windows, this argument is ignored. If there are changes to the workbook but the workbook does not appear in any other open windows, this argument specifies whether changes should be saved, as shown in the following list.

    true. Saves the changes to the workbook. If there is not yet a file name associated with the workbook, then FileName is used. If FileName is omitted, the user is asked to supply a file name.

    false. Does not save the changes to the workbook.

    Omitted. Displays a dialog box asking the user whether or not to save changes.

  • Filename
    Type: System.Object

    Save changes under this file name.

  • RouteWorkbook
    Type: System.Object

    If the workbook does not need to be routed to the next recipient (if it has no routing slip or has already been routed), this argument is ignored. Otherwise, Microsoft Office Excel routes the workbook as shown in the following list.

    true. Sends the workbook to the next recipient.

    false. Does not send the workbook.

    Omitted. Displays a dialog box asking the user whether the workbook should be sent.

Remarks

Closing a workbook using this method does not run any Auto_Close macros in the workbook. Use the RunAutoMacros method to run the macros.

Optional Parameters

For information on optional parameters, see The Variable missing and Optional Parameters in Office Solutions.

Examples

The following code example uses the Close method to close the current workbook without saving any changes.

This example is for a document-level customization.

Private Sub WorkbookClose()
    Me.Close(False, False)
End Sub
private void WorkbookClose()
{
    this.Close(false, false, missing);
}

.NET Framework Security

See Also

Reference

Workbook Class

Workbook Members

Microsoft.Office.Tools.Excel Namespace