Consulting

Results 1 to 1 of 1

Thread: Eureka!! Finally a realiable and seemingly robust DropDownList CC Change Event.

  1. #1
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,040
    Location

    Eureka!! Finally a realiable and seemingly robust DropDownList CC Change Event.

    Most regulars here have heard me grouse before about Microsoft's shortsightedness wrt a reliable built-in content control change event. Well they are still shortsighted and did nothing to improve CCs with Word 2019.

    However, immobilized this weekend nursing a cracked rib, I have discovered a solution to a nagging problem with a pseudo DropDownList change event using the CustomXMLPart events.
    As some of you may know, using one of the CC built-in events, you can react to a change made in a DDL and set the value of another customXMLnodes without having to first exit the DDL CC. So for example, you can select A in the DDL and cause “Apples” to appear in an associated mapped text CC, but you can’t do anything in the document object itself while in that event.

    A couple of years ago, I discovered the CustomXMLPart events and with it, I am able to change the value of a DDL and interact directly with the document e.g., write the word “Apples” to an upmapped text CC or even a table cell. The nagging problem was the Placeholder Text list entry. If you stuck with the “Choose an Item” with corresponding Null value then the event didn’t fire. In order to make it work, you and to set the as dummy PHT of some number of blank spaces “ “


    Okay, that was probably good enough but as I said, nagging ��



    There are 3 events associated with the CustomXMLPart object, AddNode, DeleteNode and ReplaceNode. Well, I discovered yesterday that what actually happens when the user changes a mapped DDL from PHT to one of the other listed items, the “AddNode” event is fired. When they select the PHT item from one of the other listed items, the “DeleteNode” event is fired. When they change from one listed (non PHT) item to another listed (non PHT) item the ReplaceNode event is fired.



    I’ve now managed to put together a process that leverages all three events to create a seemingly robust DDL change event. Examples and code attached.

    Last edited by gmaxey; 09-08-2019 at 09:03 AM. Reason: Put the wrong attachment in earlier message.
    Greg

    Visit my website: http://gregmaxey.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •