Document.BeforeClose الحدث

يحدث مباشرة قبل إغلاق مستند.

مساحة الاسم:  Microsoft.Office.Tools.Word
التجميع:  Microsoft.Office.Tools.Word (في Microsoft.Office.Tools.Word.dll)

بناء الجملة

'إقرار
Event BeforeClose As CancelEventHandler
event CancelEventHandler BeforeClose

ملاحظات

يتم إجراء حدث قبل إغلاق مستند. لمنع إغلاق مستند، قم بتعيين Cancelوسيطة من المتوفر CancelEventArgsكائن إلى true.

أمثلة

يلي تعليمات برمجية المثال تعرض صندوق رسالة قبل إغلاق مستند. Th هو المثال هو للوظيفة الإضافية المستوى تطبيق.

Private Sub DocumentBeforeClose()
    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    AddHandler vstoDoc.BeforeClose, AddressOf ThisDocument_BeforeClose
End Sub

Private Sub ThisDocument_BeforeClose(ByVal sender As Object, _
    ByVal e As System.ComponentModel.CancelEventArgs)
    System.Windows.Forms.MessageBox.Show("The document is closing.")
End Sub
private void DocumentBeforeClose()
{
    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    vstoDoc.BeforeClose += new System.ComponentModel.CancelEventHandler(ThisDocument_BeforeClose);
}

void ThisDocument_BeforeClose(object sender, System.ComponentModel.CancelEventArgs e)
{
    System.Windows.Forms.MessageBox.Show("The document is closing.");
}

أمن NET Framework.

راجع أيضًَا

المرجع

Document واجهة

Document الأعضاء

Microsoft.Office.Tools.Word مساحة الاسم