Freigeben über


SaveEventArgs Interface

Provides data for the BeforeSave event.

Namespace:  Microsoft.Office.Tools.Word
Assemblies:   Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)
  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

Syntax

'Declaration
<GuidAttribute("06c7ed15-2df8-4a5c-acf4-10cdd5a6a510")> _
Public Interface SaveEventArgs
[GuidAttribute("06c7ed15-2df8-4a5c-acf4-10cdd5a6a510")]
public interface SaveEventArgs

The SaveEventArgs type exposes the following members.

Properties

  Name Description
Public property Cancel Gets or sets a value indicating whether to cancel the save operation.
Public property ShowSaveAsDialog Gets or sets a value indicating whether to display the Save As dialog box.

Top

Examples

The following code example demonstrates an event handler for the BeforeSave event. When you save the document, the event handler prompts you to cancel or continue with the save operation.

This example is for a document-level customization.

Private Sub DocumentBeforeSave()
        AddHandler Me.BeforeSave, AddressOf ThisDocument_BeforeSave
    End Sub 

    Private Sub ThisDocument_BeforeSave(ByVal sender As Object, ByVal e As Microsoft.Office.Tools.Word.SaveEventArgs)
        If MessageBox.Show("Do you want to save the document?", "BeforeSave", _
            MessageBoxButtons.YesNo) = DialogResult.No Then
            e.Cancel = True 
        End If 
    End Sub
private void DocumentBeforeSave()
{
    this.BeforeSave += new Microsoft.Office.Tools.Word.SaveEventHandler(ThisDocument_BeforeSave);
}

void ThisDocument_BeforeSave(object sender, Microsoft.Office.Tools.Word.SaveEventArgs e)
{
    if (MessageBox.Show("Do you want to save the document?", "BeforeSave",
        MessageBoxButtons.YesNo) == DialogResult.No)
    {
        e.Cancel = true;
    }
}

See Also

Reference

Microsoft.Office.Tools.Word Namespace