PDA

View Full Version : Repeating section content control, NodeAfterInsert event



Hawkansson
12-02-2016, 12:24 AM
Hi, following some guides by Greg Maxey and "Wordmeister" I've managed to detect when a new node is inserted or deleted by a mapped repeating section content Control.

What I would want to achieve, is that whenever a new row is inserted or deleted in table 1 (the repeating section cc), table 2 is updated accordingly, i.e if a row is added in table 1, one row is added in table 2.

But it seems the NodeAfterInsert event can't deal with selection changes or table manipulations. As an example the following could will work:



Private Sub cxp_NodeAfterInsert(ByVal NewNode As Office.CustomXMLNode,ByVal InUndoRedo As Boolean)

MsgBox "ping"

End Sub


... but this would not:


Private Sub cxp_NodeAfterInsert(ByVal NewNode As Office.CustomXMLNode, ByVal InUndoRedo As Boolean)

Selection.MoveDown

End Sub


The table with my repeated section cc gets totally messed up. My landscape page setup changes to portrait and I've also seen that Word becomes unresponsive.

Any suggestions or tips? Are there other ways of detecting that my table changes, and fire events on that?

Best regards, David

Hawkansson
12-02-2016, 06:38 AM
Update: It only fails if I use the Plus-symbol showing to the right of the row in my repeating section content control. Not if I use Right click and Insert after or Insert Before.

gmaxey
12-02-2016, 07:04 AM
David,

For as amazing as they are (sometimes), content controls remain diamonds in rough. Microsoft seems more interested in keeping up a trending interface than realizing and providing the amazing potential CCs hold. Two glaring shortcomings are 1) No built-in change event (Why?, activeX and Userform controls have had a change event since the beginning) 2) As you have encountered, the document object is not accessible when in a CXMLPart event (Why? Don't know but PPPlanning leads to PPResults).

All I can suggest is to try mapped CCs Map table 1 CC and copy and paste it as table 2. http://gregmaxey.com/word_tip_pages/content_control_tools.html

or, and I've not tried it with RSCCs, you might wrap it in a RT control and try my custom change event:
http://gregmaxey.com/word_tip_pages/content_control_custom_events.html

Hawkansson
12-06-2016, 12:08 AM
Thank you Greg, seems Microsoft is not quite there yet when it comes to content controls. I will look into your suggestions. Appreciate your help.

/David