View Single Post
 
Old 08-31-2020, 05:13 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,975
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Greg's Document_ContentControlOnExit macro is showing how to retrieve an array of data from a single list item in a Content Control. It assumes that each entry in a dropdown CC list contains a displayed name plus a 'value' which contains a series of values separated by a "|" symbol. Then when the user makes a selection with that CC, the macro fires to transfer the other data into other content controls (date, address etc).

There are threads on this forum where this type of functionality was requested. https://www.msofficeforums.com/word-...own-lists.html
I'm not convinced this macro is what you need for your project but it can be useful for other requirements.

The question I have for you is does the number of rows in your data source vary? Your initial sample shows 7 entries and the most recent shows an extra one added. If this project has to adapt to variable numbers of participants it makes the complexity a lot bigger as paragraphs will need to be added/removed accordingly depending on that count.

Charles' suggestion of Mail Merge is a possibility but it appears you want all the rows of data in the one interwoven file so I'm going to recommend you stay with the CC + code approach. I'm thinking you might get mileage from repeating content controls and will need to import the excel data as embedded xml to set this up.

Because you are using code to transfer the data from Excel to CCs in Word, there are essentially two ways to do this:
1. Write the excel data to an embedded xml file and use linked CCs to display that data
2. Write the excel data direct to CCs (which may or may not be linked to embedded xml)

Option 2 is limited to a fixed number of records unless you then include code to expand or reduce the paragraphs for each new record. Option 1 may be more automated to deal with variable record counts if the xml is structured well enough. I will have a play with your provided files to see what I can add.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote