Laurent Kempé

Hi

Is there a way in the BeforeDelete event of XMLNode in Word to cancel the deletion

Thanks




Re: Visual Studio Tools for Office BeforeDelete event of XMLNode in Word, Delete cancellation

Misha Shneerson

You can not cancel. Although this is a bummer there probably is a workaround.

I did not try this but if I would have to make it work somehow I would capture the deleted range as an XML and then re-insert it in the next SelectionChange event handler.






Re: Visual Studio Tools for Office BeforeDelete event of XMLNode in Word, Delete cancellation

Steve 5656565656

I had this same problem. In my case, I resolved it by adding document protection to my entire document, and then Word allowed me to make protection exceptions. I then made protection exceptions to my entire document except my XML nodes. (Keep in mind that you need to turn on protection at run time or the document won't load, you will get an exception thrown, but I was able to set up my document with the protection exceptions at design time

ThisApplication.ActiveDocument.Protect(Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyReading, ref m, ref m, ref m, ref m);

)

I needed a way to prevent my XML nodes from being accidentally deleted by the user. Hope this helps anyone.