Partager via


Close Method

For the Explorer object, the Close method closes the explorer.

For an Inspector or Microsoft Outlook item object, the Close method closes the inspector or item and optionally saves changes to the displayed Outlook item.

expression**.Close(SaveMode)**

*expression    * Required. An expression that returns one of the objects in the Applies To list.

OlInspectorClose

OlInspectorClose can be one of these OlInspectorClose constants.
olDiscard Discard all changes without prompting.
olPromptForSave Prompt to save or discard all changes.
olSave Save all changes without prompting.

Example

This Visual Basic for Applications (VBA) example saves and closes the item displayed in the active inspector without prompting the user. To run this example, you need to have an item displayed in an inspector window.

Sub CloseItem()
    Dim myolapp As Outlook.Application
    Dim myinspector As Outlook.Inspector
    Dim myItem As Outlook.MailItem
    Set myolapp = CreateObject("Outlook.Application")
    Set myinspector = myolapp.ActiveInspector
    Set myItem = myinspector.CurrentItem
    myItem.Close olSave
End Sub

If you use Microsoft Visual Basic Scripting Edition (VBScript) in an Outlook form, you do not create the Application object, and you cannot use named constants. This example shows how to create a mail item, add a recipient, and close the item after prompting the user to save changes.

Set myItem = Application.CreateItem(0)
myItem.Recipients.Add "David Goodhand"
myItem.Close 2

Applies to | AppointmentItem Object | ContactItem Object | DistListItem Object | DocumentItem Object | Explorer Object | Inspector Object | JournalItem Object | MailItem Object | MeetingItem Object | NoteItem Object | PostItem Object | RemoteItem Object | ReportItem Object | TaskItem Object | TaskRequestAcceptItem Object | TaskRequestDeclineItem Object | TaskRequestItem Object | TaskRequestUpdateItem Object

See Also | CustomAction Event | CustomPropertyChange Event | Forward Event | Open Event | PropertyChange Event | Read Event | Reply Event | ReplyAll Event | Saved Property | Send Method | Using events with Automation | Write Event