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.
SaveMode This argument is used with all objects in the Applies To list except for the Explorer object. Required OlInspectorClose. The close behavior. If the item displayed within the inspector has not been changed, this argument has no effect.
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