Word DocumentBeforeClose doesn't appear to work correctly

Add-in Express™ Support Service
That's what is more important than anything else

Word DocumentBeforeClose doesn't appear to work correctly


objWordApp_DocumentBeforeClose(ByVal Doc As Word.Document, ByRef Cancel As Boolean) Handles objWordApp.DocumentBeforeClose

When the above method is called (via word's document close or app close event)it doesn't matter whether the variable "Cancel" is true or false the document still closes. I am trying to cancel the close event so the document/app doesn't close.

Any help?
Posted 29 Jun, 2005 23:28:36 Top
Sergey Grischenko

Add-in Express team

Posts: 7187
Joined: 2004-07-05
Hi Glen.

Why don't you use the ADXWordAppEvents component? See the code below. It works fine.

Private Sub adxWordEvents_DocumentBeforeClose(ByVal sender As Object, ByVal e As AddinExpress.MSO.ADXHostBeforeActionEventArgs) Handles adxWordEvents.DocumentBeforeClose

If MessageBox.Show("Close???", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = DialogResult.Cancel Then
e.Cancel = True
End If

End Sub
Posted 30 Jun, 2005 06:58:04 Top


Thanks Sergey
Posted 01 Jul, 2005 02:47:24 Top