I need to determine if any new ContentControls were inserted into a Word 2010 (docx) document after a paste so that I can create a new XML node to which I can map them.
The way I see it, there are two challenges:
Once I have a collection of the new ContentControls, I already have functions that can check for prior existence, and create new mappings if the ContentControls are new. I just need to be able to detect the presence of a new ContentControl when it is inserted.
****UPDATE****
I have not been able to successfully check the clipboard contents for ContentControls. I cannot enumerate throught the clipboard data to find the controls.
There is an event handler built in that fires after a ContentControl is added:
Private Sub Document_ContentControlAfterAdd(ByVal NewContentControl As ContentControl, ByVal InUndoRedo As Boolean)
Put the event handler in the ThisDocument module, (you can automatically create it from the VBA dropdown when inside of ThisDocument).
It doesn't matter how the control is added (both paste and insert commands trigger the event). Each new ContentControl fires the event. I can test each one to see if it is already in the document.
Works like a charm.