Supportnet / Forum / Textverarbeitung
Das Schließen verhindern/abbrechen
Frage
Hallo,
ich suche nach einer Möglichkeit das Schließen der Word-Datei abzubrechen. In Excel gibt es ein Ereignis:[code]Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
End Sub[/code]Hat jemand ein ähnliches Beispiel für Word?
Antwort 1 von stirlitz
Hallo maxim66,
Mit folgendem Code muss es gehen. Kopiere ihn in das Klassenmodul "ThisDocument"
Gruß stirlitz
Mit folgendem Code muss es gehen. Kopiere ihn in das Klassenmodul "ThisDocument"
Private WithEvents wrdApp As Word.Application
Private Sub Document_New()
If wrdApp Is Nothing Then Set wrdApp = ThisDocument.Application
End Sub
Private Sub Document_Open()
If wrdApp Is Nothing Then Set wrdApp = ThisDocument.Application
End Sub
Private Sub wrdApp_DocumentBeforeClose(ByVal Doc As Document, Cancel As Boolean)
Cancel = True
End SubGruß stirlitz

