Zdarzenie DocumentBase.CloseEvent
Występuje, gdy dokument jest zamykany.
Przestrzeń nazw: Microsoft.Office.Tools.Word
Zestaw: Microsoft.Office.Tools.Word.v4.0.Utilities (w Microsoft.Office.Tools.Word.v4.0.Utilities.dll)
Składnia
'Deklaracja
Public Event CloseEvent As DocumentEvents2_CloseEventHandler
public event DocumentEvents2_CloseEventHandler CloseEvent
Przykłady
Poniższy przykład kodu wyświetla komunikat, gdy dokument jest zamykany.Aby wykorzystać ten przykład, należy uruchomić go z ThisDocument klasy w projekcie na poziomie dokumentu.
Private Sub DocumentCloseEvent()
AddHandler Me.CloseEvent, AddressOf ThisDocument_CloseEvent
End Sub
Sub ThisDocument_CloseEvent()
MessageBox.Show("The document is closing.")
End Sub
private void DocumentCloseEvent()
{
this.CloseEvent += new Microsoft.Office.Interop.Word.DocumentEvents2_CloseEventHandler(ThisDocument_CloseEvent);
}
void ThisDocument_CloseEvent()
{
MessageBox.Show("The document is closing.");
}
Zabezpieczenia programu .NET Framework
- Pełne zaufanie do bezpośredniego wywołującego. Tego elementu członkowskiego nie można używać w kodzie częściowo zaufanym. Aby uzyskać więcej informacji, zobacz Przy użyciu bibliotek z częściowo zaufanego kodu..