Discussion:
How do I capture the deletion notifications of objects in document
(too old to reply)
古泉
2006-09-02 14:43:01 UTC
Permalink
I write a word addin with VC6.0. It add some button in word 2000 or higher
versions. The button can create my own activeX control in current document.
How can i capture the deletion notifications of objects,such as the
controls or
the tables in current document?
thanks for your care!
Jezebel
2006-09-02 22:48:25 UTC
Permalink
You can trap the Application.DocumentChange event, but your code will have
to be *extremely* efficient or you'll disrupt the user.
Post by 古泉
I write a word addin with VC6.0. It add some button in word 2000 or higher
versions. The button can create my own activeX control in current document.
How can i capture the deletion notifications of objects,such as the
controls or
the tables in current document?
thanks for your care!
Jean-Guy Marcil
2006-09-03 00:20:14 UTC
Permalink
Post by Jezebel
You can trap the Application.DocumentChange event, but your code will
have to be *extremely* efficient or you'll disrupt the user.
Don't you mean the WindowSelectionChange event?
The DocumenmtChange event is fired when documents are created, opened or
activated.

In any case, you are right about the "*extremely* efficient", and this will
be complex as well.

Or, you could highjack the built in cut/delete commands with a couple of
subs, this would be easier than implementing a class module and the
application event:

'_______________________________________
Sub EditCut()

If Selection.Information(wdWithInTable) Then
MsgBox "You can't delete tables."
Else
Selection.Cut
End If

End Sub
'_______________________________________

'_______________________________________
Sub EditClear()

If Selection.Information(wdWithInTable) Then
MsgBox "You can't delete tables."
Else
Selection.Delete
End If

End Sub
'_______________________________________

But, this is still complicated. For example, what if the user selects an
area of text that starts outside a table and finishes outside a able but
includes a table? That table will be deleted.

The code would have to be complete and thoroughly tested before being
distributed.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
***@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Jezebel
2006-09-03 01:46:23 UTC
Permalink
Post by Jean-Guy Marcil
Don't you mean the WindowSelectionChange event?
The DocumenmtChange event is fired when documents are created, opened or
activated
Quite right.

Loading...